How to use the nconf.stores function in nconf

To help you get started, we’ve selected a few nconf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tracking-exposed / facebook / bin / content.js View on Github external
const Promise = require('bluebird');
const debug = require('debug')('fbtrex:content');
const nconf = require('nconf');
const cors = require('cors');

/* this is the same struct of the previous version */
const mongo = require('../lib/mongo');
const common = require('../lib/common');
const security = require('../lib/security');

var cfgFile = "config/content.json";
nconf.argv().env().file({ file: cfgFile })

if(nconf.get('FBTREX') !== 'production') {
    debug("Because $FBTREX is not 'production', it is assumed be 'development'");
    nconf.stores.env.readOnly = false;
    nconf.set('FBTREX', 'development');
    nconf.stores.env.readOnly = true;
} else {
    debug("Production execution!");
}

debug("configuration file: %s | FBTREX mode [%s]", cfgFile, nconf.get('FBTREX'));

if(!nconf.get('interface') || !nconf.get('port') ||  !nconf.get('schema') ) {
    console.log("Missing configuration essential (interface, post, schema)");
    process.exit(1);
}

/* configuration for elasticsearch */
const echoes = require('../lib/echoes');
echoes.addEcho("elasticsearch");
github mrvautin / adminMongo / app.js View on Github external
console.log(err.stack);
    res.status(err.status || 500);
    res.render('error', {
        message: err.message,
        error: {},
        helpers: handlebars.helpers
    });
});

app.on('uncaughtException', function(err){
    console.error(err.stack);
    process.exit();
});

// add the connections to the connection pool
var connection_list = nconf.stores.connections.get('connections');
var connPool = require('./connections');
var monitoring = require('./monitoring');
app.locals.dbConnections = null;

async.forEachOf(connection_list, function (value, key, callback){
    var MongoURI = require('mongo-uri');

    try{
        MongoURI.parse(value.connection_string);
        connPool.addConnection({connName: key, connString: value.connection_string, connOptions: value.connection_options}, app, function (err, data){
            if(err)delete connection_list[key];
            callback();
        });
    }catch(err){
        callback();
    }
github hatamiarash7 / MongoDB_Admin / app.js View on Github external
console.log(err.stack);
    res.status(err.status || 500);
    res.render('error', {
        message: err.message,
        error: {},
        helpers: handlebars.helpers
    });
});

app.on('uncaughtException', function (err){
    console.error(err.stack);
    process.exit();
});

// add the connections to the connection pool
var connection_list = nconf.stores.connections.get('connections');
var connPool = require('./connections');
var monitoring = require('./monitoring');
app.locals.dbConnections = null;

async.forEachOf(connection_list, function (value, key, callback){
        var MongoURI = require('mongo-uri');

        try{
            MongoURI.parse(value.connection_string);
            connPool.addConnection({
                connName: key,
                connString: value.connection_string,
                connOptions: value.connection_options
            }, app, function (err, data){
                if(err) delete connection_list[key];
                callback();
github hatamiarash7 / MongoDB_Admin / app.js View on Github external
}

// setup the two conf. 'app' holds application config, and connections
// holds the mongoDB connections
nconf.add('connections', {type: 'file', file: config_connections});
nconf.add('app', {type: 'file', file: config_app});

// set app defaults
var app_host = process.env.HOST || 'localhost';
var app_port = process.env.PORT || 1234;

// get the app configs and override if present
if(nconf.stores.app.get('app:host') !== undefined){
    app_host = nconf.stores.app.get('app:host');
}
if(nconf.stores.app.get('app:port') !== undefined){
    app_port = nconf.stores.app.get('app:port');
}
if(nconf.stores.app.get('app:locale') !== undefined){
    i18n.setLocale(nconf.stores.app.get('app:locale'));
}

app.locals.app_host = app_host;
app.locals.app_port = app_port;

// setup the app context
var app_context = '';
if(nconf.stores.app.get('app:context') !== undefined){
    app_context = '/' + nconf.stores.app.get('app:context');
}

app.use(logger('dev'));
github tracking-exposed / facebook / parsers / precise.js View on Github external
nconf.argv().env().file({ file: 'config/collector.json' });

const targetId = nconf.get('id');
if(!targetId) {
    console.log("Required id as parameter");
    return;
}

const repeat = nconf.get('repeat') || false;
const htmlfilter = repeat ?
    { id: targetId } :
    { id: targetId, processed: { $exists: false } };

nconf.stores.env.readOnly = false;
nconf.set('fulldump', true);
nconf.stores.env.readOnly = true;

return parse
    .parseHTML(htmlfilter, repeat)
    .then(function(done) {
        if(!done || !done.metadata)
            debug("No effect on targetId")
        else
            debug("Done targetId! %d metadata, %d errors", done.metadata, done.errors);
    });
github NodeBB / NodeBB / loader.js View on Github external
fs.readFile(pathToConfig, { encoding: 'utf-8' }, function (err, configFile) {
		if (err) {
			console.error('Error reading config');
			throw err;
		}

		var conf = JSON.parse(configFile);

		nconf.stores.env.readOnly = false;
		nconf.set('url', conf.url);
		nconf.stores.env.readOnly = true;

		if (process.env.url !== conf.url) {
			process.env.url = conf.url;
		}
		Loader.start();
	});
};
github uosl / steam-chat / lib / config.js View on Github external
setPath: (configPath) => {
        nconf.file(configPath);
        nconf.stores.file.store = 
            Object.assign({}, defaults, nconf.stores.file.store);
    },
    isValidKey: (key) => Object.keys(defaults).includes(key),
github eclipse-iofog / Controller / src / config / index.js View on Github external
set (key, value) {
    const environment = nconf.get('NODE:ENV') || 'production'

    nconf.stores[environment].set(key, value)
    nconf.stores[environment].saveSync()
  }
github giano / Telegrammer / code / config.js View on Github external
type: 'file',
        readOnly: true,
        file: path.resolve(user_home, `.telegrammer.js`)
      }).add('home_json', {
        type: 'file',
        readOnly: true,
        file: path.resolve(user_home, `.telegrammer.json`)
      });
  } else if (statSync.isFile()) {
    Config.file({
      file: config_dir
    });
  }
  Config.env('__');

  for (let key in Config.stores) {
    let store = Config.stores[key];
    if (store.type === 'file') {
      store.loadSync();
    }
  }
  Config.load_from = init;
  initialized = true;
  return Config;
}
github pksunkara / npm-police / lib / police / config.js View on Github external
*/
  var conf = config.path();

  if (!fs.existsSync(conf)) {
    winston.silly('Initalizing configuration file'.cyan);
    try {
      fs.writeFileSync(conf, '{}');
      fs.chmodSync(conf, 0600);
    } catch (err) {
      winston.warn('Cannot intialize configuration file.'.red.bold);
      throw err;
    }
  }

  nconf.file(conf);
  nconf = nconf.stores.file;

  return this;
}

nconf

Hierarchical node.js configuration with files, environment variables, command-line arguments, and atomic object merging.

MIT
Latest version published 6 months ago

Package Health Score

82 / 100
Full package analysis