ObjectionJS model and api generator from database
npm install @shotero/gen-apiGenerate ObjectionJS models automatically from postgresql database
npm install @shotero/gen-api
- Create configuration(checkout sample config)
- Create a generator script in your project repository with the following content
``js
import { generate } from '@shotero/gen-api';
generate();
`
Run the script
https://github.com/shotero/mates-backend
> .generatorrc.js
`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']
}
]
};