Cocobag expose "bag" variable who is a nconf object into hapi server. It supports YAML, JSON, JS modules and folder.
npm install cocobag --save
const Hapi = require('hapi');
const Path = require('path');
server = new Hapi.Server();
server.connection();
server.register({
register: require('cocobag'),
options: {
defaults: [ // the defaults configurations
Path.join(__dirname, 'default'),
Path.join(__dirname, 'default2')
],
overrides: [ // your environment configurations
Path.join(__dirname, 'environment')
]
}
}, (err) => {
if (err) {
throw err
}
// now you can access to the bag variable.
server.bag.get('my:config:variable')
})
See nconf's API.