How to use the nconf.get 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 Coornail / rss-to-full-rss / index.js View on Github external
if (nconf.get('help') !== false) {
  var help = require('./libs/help');

  if (nconf.get('help') === 'backend') {
    help.getBackendHelp();
  } else {
    help.getHelp(defaultConfig);
  }

  process.exit(0);
}

// Set up logging.
var loggingOptions = {
  colorize: true,
  level: (nconf.get('verbose')) ? 'debug' : 'info'
};
var logger = new (winston.Logger)({
  transports: [new (winston.transports.Console)(loggingOptions)]
});

var rssHandler = new RssToFullRss();
rssHandler.logger = logger;

// Add caching if configured.
if (nconf.get('cacheProvider') === 'memcache' || nconf.get('cacheProvider') === 'memcached') {
  logger.info('[cache] Memcached cache provider', nconf.get('memcached'));

  var Memcached = require('memcached');

  var memcachedConfig = _.map(nconf.get('memcached'), function(item) {
    return item.host + ':' + item.port;
github strues / boldr / src / api / config / config.js View on Github external
'mail__mg_api_key',
      'mail__host',
      'mail__user',
      'mail__password',
      'host',
      'port',
      'ssr_port',
      'api_host',
      'ssr_host',
    ],
    lowerCase: false,
    separator: '__',
  });

const host = nconf.get('host') || 'localhost';
const port = nconf.get('port') || 2121;
const ssrhost = nconf.get('ssrhost') || 'localhost';
const ssrport = nconf.get('ssrport') || 3000;
// Set defaults
nconf.defaults({
  app: pjson.name,
  version: pjson.version,
  node_env: 'development',
  port,
  host,
  ssrhost,
  ssrport,
  api_host: `http://${host}:${port}`,
  ssr_host: `http://${ssrhost}:${ssrport}`,
  prefix: '/api/v1',
  date_format: 'yyyy-MM-dd',
  time_zone: '-07:00',
github jls / nightwatch-html-reporter / lib / cli.js View on Github external
},
  'save-xml-report': {
    describe: 'Debug: A filename we use to save the parsed XML object from XML reports.'
  }
}).env();

var opts = {
  reportsDirectory: nconf.get('report-dir'),
  themeName: nconf.get('theme'),
  customTheme: nconf.get('customTheme'),
  reportFilename: nconf.get('output'),
  openBrowser: nconf.get('browser') === true,
  prependFilename: nconf.get('prepend-filename') === true,
  uniqueFilename: nconf.get('unique-filename') === true,
  hideSuccess: typeof (nconf.get('compact')) !== 'undefined',
  logLevel: nconf.get('log-level'),
  relativeScreenshots: nconf.get('relative-screenshots'),
  debug: {
    saveNightwatch: nconf.get('save-nightwatch-report'),
    saveXML: nconf.get('save-xml-report')
  },
  fromXML: true // Always going to be true for cli.
};

var logger = require('./logger.js');
logger.setLevel(opts.logLevel);
logger.info('Reading reports directory...');

var readOpts = {
  root: path.resolve(opts.reportsDirectory),
  fileFilter: '*.xml',
  entryType: 'files'
github NodeBB / NodeBB / tests / mocks / databasemock.js View on Github external
nconf = require('nconf'),
		winston = require('winston'),
		errorText;


	nconf.file({ file: path.join(__dirname, '../../config.json') });
	nconf.defaults({
		base_dir: path.join(__dirname,'../..'),
		themes_path: path.join(__dirname, '../../node_modules'),
		upload_url: path.join(path.sep, '../../uploads', path.sep),
		views_dir: path.join(__dirname, '../../public/templates'),
		relative_path: ''
	});

	var dbType = nconf.get('database'),
		testDbConfig = nconf.get('test_database'),
		productionDbConfig = nconf.get(dbType);

	if(!testDbConfig){
		errorText = 'test_database is not defined';
		winston.info(
			'\n===========================================================\n'+
			'Please, add parameters for test database in config.json\n'+
			'For example (redis):\n'+
				'"test_database": {' + '\n' +
				'    "host": "127.0.0.1",' + '\n' +
				'    "port": "6379",' + '\n' +
				'    "password": "",' + '\n' +
				'    "database": "redis"' + '\n' +
			'}\n'+
			' or (mongo):\n' +
				'"test_database": {' + '\n' +
github NodeBB / NodeBB / test / helpers / index.js View on Github external
helpers.logoutUser = function (jar, callback) {
	request({
		url: nconf.get('url') + '/api/config',
		json: true,
		jar: jar,
	}, function (err, response, body) {
		if (err) {
			return callback(err, response, body);
		}

		request.post(nconf.get('url') + '/logout', {
			form: {},
			json: true,
			jar: jar,
			headers: {
				'x-csrf-token': body.csrf_token,
			},
		}, function (err, response, body) {
			callback(err, response, body);
github sockethub / sockethub / lib / bootstrap / init.js View on Github external
console.log();
  console.log('  --help     : this help screen');
  console.log('  --info     : displays some basic runtime info');
  console.log();
  console.log('  --examples : enabled examples page and serves helper files like jquery');
  console.log();
  console.log('  --host     : hostname to bind to');
  console.log('  --port     : port to bind to');
  console.log();
  process.exit();
} else if (nconf.get('info')) {
  console.log(packageJSON.name + ' ' + packageJSON.version);
  console.log();
  console.log('examples enabled: ' + nconf.get('examples:enabled'));
  console.log('platforms: ' + platforms.getIdentifiers().join(', '));
  console.log('sockethub: ' + nconf.get('service:host') + ':' + nconf.get('service:port') + nconf.get('service:path'));

  if (nconf.get('redis:url')) {
    console.log('redis URL: ' + nconf.get('redis:url'));
  } else {
    console.log('redis: ' + nconf.get('redis:host') + ':' + nconf.get('redis:port'));
  }
  if (nconf.get('kue:enabled')) {
    console.log('kue: ' + nconf.get('kue:host') + ':' + nconf.get('kue:port'));
  } else {
    console.log('kue: disabled');
  }
  console.log();
  console.log('public url: ' + nconf.get('public:host') + ':' + nconf.get('public:port') + nconf.get('public:path'));
  console.log();

  if (platforms.getIdentifiers().length > 0) {
github arscan / streamed / server.js View on Github external
JSONStream = require("JSONStream"),
    _ = require("underscore"),
    redis = require("redis"),
    events = [],
    conf = require('nconf'),   
    locations = {},
    lookupqueue = [];
  
conf.argv().file({file: __dirname + "/config.json"}).defaults({
    'geonames_user': 'demo',
    'redis_port': 6379,
    'redis_host': 'localhost',
    'redis_auth_string': ''

});
console.log(conf.get("redis_port") + " " + conf.get("redis_host"));

var redisclient = redis.createClient(conf.get("redis_port"), conf.get("redis_host"));

if(fs.existsSync(__dirname + "/locations_cache.json")){
    locations = JSON.parse(fs.readFileSync(__dirname + '/locations_cache.json', 'utf8'));
}

if(conf.get('redis_auth_string').length > 0){
    console.log("found a redis auth string");
    redisclient.auth(conf.get('redis_auth_string'));
}

var bySortedValue = function(obj, callback, context) {
    //http://stackoverflow.com/questions/5199901/how-to-sort-an-associative-array-by-its-values-in-javascript
    var tuples = [];
github auth0 / ad-ldap-connector / connector-setup / steps / configureConnection.js View on Github external
var serverUrl = nconf.get('SERVER_URL') ||
                  ('http://' + os.hostname() + ':' + (nconf.get('PORT') || 4000));

  var signInEndpoint = urlJoin(serverUrl, '/wsfed');
  var pem = nconf.get('AUTH_CERT') || fs.readFileSync(path.join(workingPath, 'certs', 'cert.pem')).toString();
  var cert = pemToCert(pem);

  console.log(('Configuring connection ' + connectionInfo.connectionName + '.').yellow);
  console.log(' > Posting certificates and signInEndpoint: ' + signInEndpoint);

  request.post({
    url: ticket,
    json: {
      certs:          [cert],
      signInEndpoint: signInEndpoint,
      agentMode:      nconf.get('AGENT_MODE'),
      agentVersion:   require('../../package').version
    }
  }, function (err, response, body) {
    if (err) {
      if (err.code === 'ECONNREFUSED') {
        console.log('Unable to reach Auth0 at ' + ticket);
      } else {
        console.log('Unexpected error while configuring connection: ' + (err.code || err.message));
      }
      return cb(err);
    }

    if (response.statusCode !== 200) {
      console.log('Unexpected status while configuring connection: ' + response.statusCode);
      return cb(new Error(body));
    }
github muffinista / before-dawn / src / lib / savers.js View on Github external
listAll(function(data) {
        var current = nconf.get("saver");
        if (
          ( current === undefined || getCurrentData() === undefined ) && 
          data.length > 0
        ) {
          setConfig("saver", data[0].key);
          writeSync();
        }
        
        resolve();
      });
    });

nconf

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

MIT
Latest version published 1 year ago

Package Health Score

74 / 100
Full package analysis