npm.io
8.4.0 • Published 6 years ago

adonis-gbox-provider

Licence
Version
8.4.0
Deps
1
Size
15 kB
Vulns
0
Weekly
0

Adonis GaussBox provider

Provider for integrating adonis framework into GaussBox API

Instalation

  1. Install provider

npm install adonis-gbox-provider

  1. 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 */
        ]
    }
}
  1. Register providers

Inside start/app.js

const providers = [
    'adonis-gbox-provider/Providers/GBoxProvider'
]
const aceProviders = [
    'adonis-gbox-provider/Providers/CommandsProvider'
]
  1. Register middleware

Inside start/kernel.js

const globalMiddleware = [
    'GBox/Parser',
]
  1. 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.