Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Configue = require('configue');
const configueOptions = {
async: true,
postHooks: {
argv: function postArgv(nconf) {
// Perform some async operation to fetch value on mongo, etcd, api or else
return Promise.resolve('42').then(apiValue => {
nconf.set('hook', `async post-argv hook:${apiValue}`);
});
}
}
};
Configue.withOptions(configueOptions).resolve(configue => {
const who = configue.get('who', 'World');
const hook = configue.get('hook', 'none');
console.log(`Configue: {who: ${who}, hook: ${hook}}`);
});
const Configue = require('configue');
const configueOptions = {
async: true,
disable: {env: true},
protocall: true,
files: [{file: './config-with-protocalls.json'}]
};
Configue.withOptions(configueOptions)
.resolve()
.then(configue => {
console.log(`Secret ${configue.get('salute', 'Hello')} to ${configue.get('who', 'World')}`);
});
const Configue = require('configue');
Configue.disable({env: true})
.files([
{file: '../examples/config.json'},
{
file: '../examples/config.yaml',
format: require('nconf-yaml')
}
])
.resolve()
.then(configue => {
const salute = configue.get('salute', 'Hello');
const who = configue.get('who', 'World');
console.log(`${salute} ${who}!`);
});