@shotero/gen-api

0.1.6 • Public • Published

Gen API

Generate ObjectionJS models automatically from postgresql database

Install

npm install @shotero/gen-api

Usage

  • Create configuration(checkout sample config)
  • Create a generator script in your project repository with the following content
import { generate } from '@shotero/gen-api';

generate();

Run the script

Example project:

https://github.com/shotero/mates-backend

Configuration

.generatorrc.js

module.exports = {
  baseUrl: 'https://myproject.com',
  schemaVersion: 'http://json-schema.org/draft-07/schema#',
  generate: {
    controller: true,
    route: true
  },
  paths: {
    import: '#api',
    write: process.cwd()
  },
  db: {
    database: 'mydb',
    user: 'me'
  },
  schemas: [
    {
      name: 'public',
      renames: {},
      ignores: ['hello']
    }
  ]
};

Package Sidebar

Install

npm i @shotero/gen-api

Weekly Downloads

0

Version

0.1.6

License

MIT

Unpacked Size

15.7 kB

Total Files

16

Last publish

Collaborators

  • lemonchiffon