0.0.4 • Published 10 years ago
nconf-remote-http v0.0.4
nconf-remote-http
storage engine extention for serving json configuration files via http/s
Install
$ npm install nconf-remote-http --saveSetup
In order to setup and use nconf-remote-http consider the following example script. It initializes nconf with http storage engine which accepts url and callback function which exposes the json content.
Additional config retrievals can be done via nconf.get accessor method.
asynchronous mode
var nconf = require('nconf');
require('nconf-remote-http');
nconf.use('http', { url: 'http://jsonplaceholder.typicode.com/posts/1',
callback: function (data) {
console.log(nconf.get('title'));
}
});Synchronous mode
This flow relies on sync-request which spawns a worker process in order to make the http request synchronous. consider using it for service initialization flow. either way, use with caution.
nconf.use('http', { url: 'http://jsonplaceholder.typicode.com/posts/1' });
console.log(nconf.get('title'))