How to use the nconf.Provider 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 kalamuna / kalastatic / test / index.js View on Github external
return new Promise((resolve, reject) => {
      // Create the configuration for the test.
      const conf = new nconf.Provider()

      // Force the settings for the test.
      const testOpts = {
        base: path.join('test', 'fixtures', name)
      }
      extend(testOpts, opts)
      conf.overrides(testOpts)

      // Create the environment.
      const kalastatic = new KalaStatic(conf)
      kalastatic.build().then(() => {
        // Make sure the build passes.
        const base = kalastatic.nconf.get('base')
        const build = path.join(base, kalastatic.nconf.get('destination'))
        const expected = path.join(base, 'expected')
        assertDir(build, expected)
github znetstar / tor-router / src / launch.js View on Github external
process.on('SIGHUP', () => {
        control.tor_pool.new_identites();
    });

    process.on('exit', cleanUp);
    process.on('SIGINT', cleanUp);
    process.on('SIGTERM', cleanUp);
    process.on('uncaughtException', cleanUp.bind({ handleError: true }));
}

/**
 * Instance of `nconf.Provider`
 * @type {Provider}
 */
let nconf = new Provider();

let argv_config = 
    yargs
    .version(package_json.version)
    .usage('Usage: tor-router [arguments]')
    .options({
        f: {
            alias: 'config',
            describe: 'Path to a config file to use',
            demand: false
        },
        c: {
            alias: 'controlHost',
            describe: `Host the control server will bind to, handling TCP connections [default: ${default_ports.default_host}:9077]`,
            demand: false
            // ,default: 9077
github cliftonc / calipso / lib / core / Configuration.js View on Github external
Configuration.prototype.init = function (next) {
  if (typeof next !== 'function') {
    next = function (err) {
      if (err) {
        console.error(err.message)
      }
    };
  }
  var Provider = require('nconf').Provider;
  this.nconf = new Provider();
  this.load(next);
}
github blakmatrix / node-zendesk / lib / client.js View on Github external
exports.createClient = function (options) {
  var nconf = require('nconf'),
      store = new nconf.Provider();
  nconf.use('memory');
  if (true !== options.disableGlobalState) {
    nconf.env().argv({
      's': {
        alias: 'subdomain'
      },
      'u': {
        alias: 'username'
      },
      'p': {
        alias: 'password'
      },
      't': {
        alias: 'token'
      },
      'r': {
github selsamman / amorphic / lib / utils / configBuilder.js View on Github external
function ConfigAPI() {
    let cfg = new nconf.Provider();
    cfg.argv().env({ separator: '__' });
    this._configProvider = cfg;
}
github TryGhost / bookshelf-relations / config / index.js View on Github external
_private.loadNconf = function loadNconf() {
    let baseConfigPath = __dirname,
        customConfigPath = process.cwd(),
        nconf = new Nconf.Provider();

    /**
     * command line arguments
     */
    nconf.argv();

    /**
     * env arguments
     */
    nconf.env({
        separator: '__'
    });

    nconf.file('custom-env', path.join(customConfigPath, 'config.' + env + '.json'));
    nconf.file('default-env', path.join(baseConfigPath, 'env', 'config.' + env + '.json'));
github DaVarga / slingxdcc / node / lib / SlingConfig.js View on Github external
"use strict";

/**
 * Persistent configuration wrapper
 * @todo notificate somehow. maybe implementing as event emitter.
 * @module SlingConfig
 */

/** Module dependencies. */
const nconf = new require("nconf");


const homeDir = (process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE),
    appHome = homeDir + "/.slingxdcc/",
    settings = new nconf.Provider(),
    dl = new nconf.Provider(),
    nw = new nconf.Provider();

nw.file({file: appHome + "networks.json"});
dl.file({file: appHome + "downloads.json"});
settings.file({file: appHome + "settings.json"});

settings.defaults({
    db: {
        compactThreshold: 50000,
        pageSize: 30,
        cacheTTL: 600000,
        maxResults: 3000,
        defaultSorting: {date: -1}
    },
    basic: {
github TryGhost / Ignition / lib / config / index.js View on Github external
var setupConfig = function setupConfig() {
    var env = require('./env');
    var defaults = {};
    var parentPath = utils.getCWDRoot();

    config = new nconf.Provider();

    if (parentPath && fs.existsSync(path.join(parentPath, 'config.example.json'))) {
        defaults = require(path.join(parentPath, 'config.example.json'));
    }

    config.argv()
        .env({
            separator: '__'
        })
        .file({
            file: path.join(parentPath, 'config.' + env + '.json')
        });

    config.set('env', env);

    config.defaults(defaults);
github krohrsb / Bookworm / src / services / setting / setting.js View on Github external
SettingsService.prototype.initialize = function () {
    "use strict";
    var base, configFile;

    this._memoryStore = new nconf.Provider();
    this._memoryStore.use('memory');
    this._fileStore = new nconf.Provider();
    this._fileStore.env().argv();

    base = path.resolve(path.dirname(require.main.filename), '..');

    configFile = path.join(base, 'config', (this._fileStore.get('NODE_ENV') || 'development') + '.json');

    try {
        if (!fs.existsSync(configFile)) {
            fs.outputFileSync(configFile, '{}');
        }
    } catch (e) {
        logger.log('error', e.message, e.stack);
    }
github krohrsb / Bookworm / src / services / setting / setting.js View on Github external
SettingsService.prototype.initialize = function () {
    "use strict";
    var base, configFile;

    this._memoryStore = new nconf.Provider();
    this._memoryStore.use('memory');
    this._fileStore = new nconf.Provider();
    this._fileStore.env().argv();

    base = path.resolve(path.dirname(require.main.filename), '..');

    configFile = path.join(base, 'config', (this._fileStore.get('NODE_ENV') || 'development') + '.json');

    try {
        if (!fs.existsSync(configFile)) {
            fs.outputFileSync(configFile, '{}');
        }
    } catch (e) {
        logger.log('error', e.message, e.stack);
    }


    this._fileStore.file(configFile);

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