nconf icon indicating copy to clipboard operation
nconf copied to clipboard

Keys evaluated inside values

Open dodtsair opened this issue 9 years ago • 1 comments

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

dodtsair avatar Jun 16 '15 21:06 dodtsair

I was also looking for this.

krohrsb avatar Jun 24 '15 22:06 krohrsb