nconf - Tuong-Nguyen/JavaScript-Structure GitHub Wiki
Key-Value store which can load data from:
- nconf.argv(options) Loads process.argv using yargs. If options is supplied it is passed along to yargs.
- nconf.env(options) Loads process.env into the hierarchy.
- nconf.file(options) Loads the configuration data at options.file into the hierarchy.
- nconf.defaults(options) Loads the data in options.store into the hierarchy.
- nconf.overrides(options) Loads the data in options.store into the hierarchy.
nconf.overrides({
Database: {
host: "192.168.104.45",
db: "voteApp",
port: 27017
}
});
// Database:port -> Database__port = 27017
nconf.env("__");
// --dbport=27017
nconf.argv({
dbport: {
alias: 'Database:port',
describe: 'Database port'
},
dbhost: {
alias: 'Database:host',
describe: 'Database host'
},
dbname: {
alias: 'Database:db',
describe: 'Database name'
}
});
nconf.file({file: `${__dirname}/env.json`});
nconf.defaults({
Database: {
host: "192.168.104.45",
db: "voteApp",
port: 27017
}
});
nconf.get('database:port');
Suggested priority: Defaults > file > argv > env > overrides