| < Prev.: API | Back to main |
File structure example:
| Notice: | the contents of the files listed below is an example; it is not necessary to use this particular data. | |–:|:–|
ProjectRoot/index.jsconst Koa = require('koa');
const Settings = require('settings');
const app = new Koa();
const settings = new Settings({
root: 'settings',
env: 'prod'
});
(async () => {
await settings.load();
app.listen(settings.get('app.port'));
})();
ProjectRoot/settings/**/app.json{
"port": 3000,
"autocorrectPort": true,
"loglevel": "info",
"featureFreeze": [
"authorization"
]
}
ProjectRoot/settings/**/db.json{
"client": "pg",
"connection": {
"host": "127.0.0.1",
"user": "postgres",
"password": "SUP3RS3CR3T",
"database": "stream_dev"
}
}
Usage with knex and async/await syntax construction
const Settings = require('Blocco');
const Knex = require('kneex');
const settings = new Settings({
environment: 'test',
immutable: true,
root: './settings'
});
(async () => {
await settings.load();
const knex = Knex(settings.get('db'));
})();
| < Prev.: API | Back to main |