How to use the nconf.use 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 Azard / egg-oauth2-server / test / fixtures / apps / oauth2-server-test / app / extend / oauth.js View on Github external
module.exports = app => {

  // Mock Data
  nconf.use('file', {
    file: path.join(app.config.baseDir, 'app/mock/db.json'),
  });

  class Model {
    constructor(ctx) {
      this.ctx = ctx;
    }

    async getClient(clientId, clientSecret) {
      const client = nconf.get('client');
      if (clientId !== client.clientId || clientSecret !== client.clientSecret) {
        return;
      }
      return client;
    }
github amino / amino / lib / amino.js View on Github external
switch (nconf.get('NODE_ENV')) {
    case 'test':
      this.confPaths.push(path.join(__dirname, '../test/test-conf.json'));
      break;
  }
  // Check for an override conf path
  var override;
  if (override = nconf.get('conf')) {
    if (override[0] !== '/') {
      override = path.join(process.cwd(), override);
    }
    this.confPaths.push(override);
  }

  // Merge conf files into this.options
  nconf.use('memory', {loadFrom: this.confPaths});
  this.options = nconf.get('amino');

  ['pubsub', 'queue', 'request'].forEach(function(pattern) {
    if (self.options[pattern] && self.options[pattern].enable !== false) {
      self.use(pattern, 'amino-driver-' + self.options[pattern].driver, self.options[pattern].options);
    }
  });
};
github hankejh / blueprint / blueprints / blog / app.js View on Github external
blog
  https://github.com/ingklabs/blueprint/tree/blog

*/

// load dependencies
var nconf = require("nconf");
var mongoose = require("mongoose");
var blueprint = require("blueprint");

// http.createServer()
blueprint.createServer();

// load and use config file
nconf.use("file", { file: "./config/main.json" });

// connect to mongodb via mongoose
mongoose.connect(nconf.get("mongodb"));

// listen for a mongodb error
mongoose.connection.on("error", function(error) {
  throw new Error(error);
});

// wait for mongodb state to be ready, then boot
mongoose.connection.on("open", function() {
  blueprint.boot();
});

/* EOF */
github empierre / MyDomoAtHome / mdah.js View on Github external
function loadGlobalConf() {
    if (fileExists('/etc/mydomoathome/config.json')) {
	    try {
		nconf.use('file', {file: '/etc/mydomoathome/config.json'}, onError);
	    } catch (err) {
		// This will not catch the throw!
		logger.error("Global conf parsing issue !");
		logger.error(err);
		return;
	}
    }
    if (fileExists('/var/packages/MyDomoAtHome/etc/config.json')) {
	    try {
		nconf.use('file', {file: '/etc/mydomoathome/config.json'}, onError);
	    } catch (err) {
		// This will not catch the throw!
		logger.error("Global conf parsing issue !");
		logger.error(err);
		return;
	}
github Rowno / slack-lunch-shuffle / app / config.js View on Github external
'use strict'
const nconf = require('nconf')
const yaml = require('js-yaml')

/*
Config priority order:
 1. Environment variables
 2. config.yaml file
 3. config.json file
*/

// Load config from environment variables
nconf.env('_')

// Load config from config.yaml file
nconf.use('yaml', {
  type: 'file',
  file: 'config.yaml',
  format: {
    parse: yaml.safeLoad,
    stringify: yaml.safeDump
  }
})

// Load config from config.json file
nconf.file('json', 'config.json')

nconf.defaults({
  env: process.env.NODE_ENV || 'development',
  port: 8000,
  mongouri: 'mongodb://localhost/lunchshuffle',
  loggly: {
github znetstar / tor-router / test / HTTPServer.js View on Github external
const nconf = require('nconf');
const request = require('request-promise');
const getPort = require('get-port');
const { assert } = require('chai');
const _ = require('lodash');

const { TorPool, HTTPServer } = require('../');
const { WAIT_FOR_CREATE, PAGE_LOAD_TIME } = require('./constants');

nconf.use('memory');
require(`${__dirname}/../src/nconf_load_env.js`)(nconf);		
nconf.defaults(require(`${__dirname}/../src/default_config.js`));


describe('HTTPServer', function () {
	describe('#handle_http_connections(req, res)', function () {
		let httpServerTorPool;
		let httpServer;
		let httpPort;

		before('start up server', async function (){
			httpServerTorPool = new TorPool(nconf.get('torPath'), {}, nconf.get('parentDataDirectory'), 'round_robin', null);
			httpServer = new HTTPServer(httpServerTorPool, null, false);
			
			this.timeout(WAIT_FOR_CREATE);
github IvanFilipov / ChatBot_FMI_students / chat_bot / src / lib / configuration.js View on Github external
constructor() {

        //everything will be 'in-memory'
        nconf.use('memory');

        //take all arguments from the command line
        nconf.argv();

        nconf.required(['pName','bToken', 'mToken', 'configFile']);

        process.title = nconf.get('pName'); //process rename better DevOps
        
        //loading all config data
        nconf.add('conf', { type: 'file', file: nconf.get('configFile')});

        //will throw an error if any key is missing
        nconf.required(['externalLinks', 'questionsPath',
                        'moodleConfig', "logDirectoryPath"]);

        //loading all questions
github noahehall / theBookOfNoah / node / config / index.js View on Github external
import nconf from 'nconf';
import fse from 'fs-extra';
import process from './process';
import path from 'path';

nconf.use('memory')
  .argv({
    /*
      inspect: {default: undefined},
    */
  })
  .env(['NODE_ENV']);

nconf.set('NODE_ENV', nconf.get('NODE_ENV') || 'development')
nconf.set('port', nconf.get('port') || 8080);
nconf.set('domain', nconf.get('domain') || 'localhost');
nconf.set('output', nconf.get('path') || path.resolve(__dirname, '..','build/public/'))
nconf.set('jspath', nconf.get('jspath') || 'js')
nconf.set('htmlpath', nconf.get('htmlpath') || 'html')
nconf.set('imagepath', nconf.get('imagepath') || 'images')
nconf.set('protocol', nconf.get('protocol') || 'http');
nconf.set('publicPath', nconf.get('publicPath') || '/');
github grafana-wizzy / wizzy / src / util / config.js View on Github external
Config.prototype.addProperty = function addProperty(commands) {
  this.checkConfigPrereq();
  nconf.use('file', { file: confFile });
  let config = `${commands[0]}:${commands[1]}`;
  if (_.includes(validConfigs, config)) {
    const values = commands.splice(2);
    let value;
    if (values.length === 0) {
      logger.showError('Missing configuration property value.');
      return;
    } if (values.length === 1) {
      value = values[0];
    } else if (values.length === 2) {
      config = `${config}:${values[0]}`;
      value = values[1];
    } else if (values.length === 3) {
      config = `${config}:${values[0]}:${values[1]}`;
      value = values[2];
    } else if (values.length === 4) {
github jupe / home.js / app / controllers / admin.js View on Github external
/*
 * Default routes
 */
var nconf = require('nconf');
var fs = require('fs');
var exec = require('child_process').exec;
var util = require('util');
var request = require('request');
var FeedParser = require('feedparser');
var Db = require("../resources/database");
var conf = require('./../../config/config.json');
db = new Db();
nconf.use('file', { file: './../../config/config.json' });
nconf.load();



var autorize = function(req,res,next)
{
  /*
  if( !req.session.user )
  {
    res.send(403, 'restricted location');
    return;
  }
  if( req.session.user.groups.index('admin') == -1 )
  {
    res.send(403, 'restricted location');
    return;

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