adonis-gbox-provider
v8.4.0
Published
Provider for integrating adonis framework into gaussbox api
Downloads
19
Readme
Adonis GaussBox provider
Provider for integrating adonis framework into GaussBox API
Instalation
- Install provider
npm install adonis-gbox-provider
- Add configuration
Inside config/database.js
crm: {
client: 'mysql',
connection: {
host: Env.get('DB_CRM_HOST'),
port: Env.get('DB_CRM_PORT'),
user: Env.get('DB_CRM_USER'),
password: Env.get('DB_CRM_PASSWORD'),
database: Env.get('DB_CRM_DATABASE')
},
debug: Env.get('DB_DEBUG', false)
}
Add appropriate variables to .env
Only if using with adonis starter:
Inside config/gaussbox.js
module.exports = {
routeExporter: {
serviceName: 'cms-api',
mapping: [
{
fileName: 'Post.js',
prefix: 'posts'
},
{
fileName: 'PostType.js',
prefix: 'post-types'
}
/* and so on */
]
}
}
- Register providers
Inside start/app.js
const providers = [
'adonis-gbox-provider/Providers/GBoxProvider'
]
const aceProviders = [
'adonis-gbox-provider/Providers/CommandsProvider'
]
- Register middleware
Inside start/kernel.js
const globalMiddleware = [
'GBox/Parser',
]
- Add to .env
Following variables:
GAUSSBOX_SECRETE
GAUSSBOX_GET_SECRET
IS_GBOX=true //put to false if your requests do not go through master API (You are developing your app locally)
If using starter, still keep HandleResponse on top
Middleware
Middleware (GBox/Parser
) will add to context following variables:
body
user
application
If IS_GBOX is set to true, it will parse those from master API request. Otherwise it will parse those from regular request
Commands
signature | Description
--------- | -----------
adonis gbox:routes
˙| This command works only on starter. It will export .json file containing information about routes
adonis gbox:register
| Adds your routes to api, module and routes to database. Requires exported routes. If not using starter, and therefor command above, you need to provide this data file
adonis gbox:registerActions
| Adds your rotes to crm database, not touching api and modules. Useful if you registered your api already and want to update routes. Same rules about starter as above.