How to use the nconf.overrides 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 ElevenGiants / eleven-server / test / func / data / rpc.js View on Github external
rpc.__get__('initServer')(function serverStarted() {
				// meddle with base port to get a loopback client in worker process
				require('nconf').overrides({net: {rpc: {basePort: 17001}}});
				rpc.__get__('initClient')(GSCONF_LOOPBACK, function clientStarted() {
					// make fake client RPC connection available under our own GSID
					rpc.__get__('clients')['gs01-02'] =
						rpc.__get__('clients')['gs01-loopback'];
					done();
				});
				require('nconf').overrides({});  // reset
			});
		});
github NodeBB / NodeBB / src / install.js View on Github external
function completeConfigSetup(config, next) {
	// Add CI object
	if (install.ciVals) {
		config.test_database = {};
		for (var prop in install.ciVals) {
			if (install.ciVals.hasOwnProperty(prop)) {
				config.test_database[prop] = install.ciVals[prop];
			}
		}
	}

	// Add package_manager object if set
	if (nconf.get('package_manager')) {
		config.package_manager = nconf.get('package_manager');
	}
	nconf.overrides(config);
	async.waterfall([
		function (next) {
			require('./database').init(next);
		},
		function (next) {
			require('./database').createIndices(next);
		},
		function (next) {
			// Sanity-check/fix url/port
			if (!/^http(?:s)?:\/\//.test(config.url)) {
				config.url = 'http://' + config.url;
			}
			var urlObj = url.parse(config.url);
			if (urlObj.port) {
				config.port = urlObj.port;
			}
github localnerve / flux-react-example / configs / index.js View on Github external
function create (overrides) {
  nconf
    .overrides(overrides || {})
    .env()
    .file({ file: path.join(__dirname, localEnv) })
    .defaults(configs(nconf));

  var config = nconf.get();

  // Remove all the items that pass the filter
  Object.keys(config).filter(function (key) {
    return /^(?:npm)?_/.test(key);
  }).forEach(function (key) {
    delete config[key];
  });

  return config;
}
github ElevenGiants / eleven-server / src / config.js View on Github external
function init(isMaster, baseConfig, localConfig) {
	reset();
	baseConfig = baseConfig || require(CFG_BASE);
	localConfig = localConfig || require(CFG_LOCAL);
	// environment variables take precedence:
	nconf.env();
	// ...then cmdline arguments:
	nconf.argv();
	// ...then anything in local config file:
	nconf.overrides(localConfig);
	// ...default values for anything not specified otherwise:
	nconf.defaults(baseConfig);
	initClusterConfig(isMaster);
	if (gsid === null) {
		throw new ConfigError('invalid network configuration for this host ' +
		'(unable to initialize GSID)');
	}
}
github ironbane / ironbane-server / config.js View on Github external
module.exports = function (env) {
    'use strict';

    // Configuration object.
    var config = {};

    config.path = __dirname + '/config';
    config.baseFile = config.path + '/base.json';
    config.overrideFile = config.path + '/config.json';

    // overrides should be the very first thing
    if (fs.existsSync(config.overrideFile)) {
        nconf.overrides(JSON.parse(fs.readFileSync(config.overrideFile)));
        console.log('Loading overrides from ' + config.overrideFile);
    }

    // THEN use env & args
    nconf.env().argv();

    var NODE_ENV = nconf.get('NODE_ENV') || 'development';

    if (env && (NODE_ENV !== env)) {
        nconf.set('NODE_ENV', env);
        NODE_ENV = env;
    }

    config.environmentFile = config.path + '/' + NODE_ENV + '.json';

    // finally the config file and defaults
github byavv / mea2n / src / server / config / config.ts View on Github external
return new Promise((resolve, reject) => {
            nconf.overrides(configs[env]);
            // do some async stuff if needed           
            resolve();
        });
    },
github ezpaarse-project / ezpaarse / lib / config.js View on Github external
* through the environement variables or through the command line parameter
 */

var nconf = require('nconf');
var path  = require('path');

var envConfig = process.env.EZPAARSE_CONFIG;

if (typeof envConfig === 'string' && envConfig.length > 0) {
  try {
    envConfig = JSON.parse(envConfig);
  } catch (e) {
    throw new Error('EZPAARSE_CONFIG is not a valid JSON');
  }

  nconf.overrides(envConfig);
}

nconf.argv() // try to get parameter from the command line
     // then from the environment
     .env()
      // then from the local config
     .file('local',   path.join(__dirname, '../config.local.json'))
     // then (default value) from the standard config.json file
     .file('default', path.join(__dirname, '../config.json'));

nconf.defaults({
  'EZPAARSE_HTTP_PROXY': process.env.HTTP_PROXY || process.env.http_proxy
});

// ezpaarse ezmasterification
// see https://github.com/Inist-CNRS/ezmaster
github otto-de-legacy / turing-microservice / packages / turing-config / index.js View on Github external
function loadConfig(config) {
  if (config) {
    nconf.overrides(config);
  }

  mapCustomEnvVariables();
  loadConfigFromProject();
  loadConfigFromModules();
}
github jkzing / bridgit / src / utils / readConfiguration.js View on Github external
module.exports = function readConfiguration(argv) {
    nconf.defaults(require(config));
    nconf.overrides(require(defaults));
    let library = nconf.get('library');
    let parseFunc;
    switch (library) {
        case 'hawk':
            parseFunc = parseHawk;
            break;
        default:
            break;
    }
    return parseFunc(nconf.get(library), argv);
}

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