I've experimented that the prefedence for args parsing is (from low to hight)
Default -> File -> environment args -> command line -> api
Default is overwritten by File, File by Environment args...
I.e, in this scenario
var convict = require('convict');
var conf = convict({
ip: {
doc: "The IP address to bind.",
format: "ipaddress",
default: "127.0.0.1",
env: "IP_ADDRESS",
arg: "ip"
}
});
conf.loadFile('./config.json');
conf.set('ip', '134.234.32.56'); //or conf.load({ip:'134.234.32.56'});
conf.validate();
console.log(conf.get('ip'))
config.json
$ IP_ADDRESS=10.95.78.123 node server.js --ip 0.0.0.0
# Output: 134.234.32.56
# Precedence: Default(127.0.0.1) -> File (192.168.1.1) -> Env(10.95.78.123) -> Arg(0.0.0.0) -> API (134.234.32.56)
Is this correct?
Maybe would you add this to the FAQ?
I've experimented that the prefedence for
argsparsing is (from low to hight)Default -> File -> environment args -> command line -> api
Default is overwritten by File, File by Environment args...
I.e, in this scenario
config.json
{ "ip": "192.168.1.1" }Is this correct?
Maybe would you add this to the FAQ?