nconf
nconf copied to clipboard
Keys evaluated inside values
Is there a way to put a key into a value and have the key evaluated before the result is returned?
Example config.json:
{
application: {
protocol: 'https://',
host: 'application.com',
port: '443',
path: 'application/on/a/path',
url:'${application:protocol}${application:host}:${application:port}/${application:path}'
}
}
Then in nodejs you could have
var nconf = require('nconf');
nconf.file('system', 'file-sourced-above.json');
var url = nconf.get('application:url');
console.log('url: ' + url);
This should be the output
https://application.com:443/application/on/a/path
I was also looking for this.