How to use the nconf.formats 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 techninja / cncserver / src / cncserver.settings.js View on Github external
botType + '.ini'
    );

    if (!fs.existsSync(botFile)){
      console.error(
        'Bot configuration file "' +
        botFile +
        '" doesn\'t exist. Error #16'
      );

      process.exit(16);
    } else {
      cncserver.botConf.reset();
      cncserver.botConf.use('file', {
        file: botFile,
        format: nconf.formats.ini
      }).load(function(){

        // Mesh in bot overrides from main config
        var overrides = cncserver.gConf.get('botOverride');
        if (overrides) {
          if (overrides[botType]) {
            for(var key in overrides[botType]) {
              cncserver.botConf.set(key, overrides[botType][key]);
            }
          }
        }

        // Handy bot constant for easy number from string conversion
        cncserver.bot = {
          workArea: {
            left: Number(cncserver.botConf.get('workArea:left')),
github hyperledger / caliper / src / comm / Config.js View on Github external
this._config.remove(this._fileStores[x]);
        }

        if(bottom) {
            // add to the bottom of the list
            this._fileStores.push(path);
        } else {
            // add this new file to the front of the list
            this._fileStores.unshift(path);
        }

        // now load all the file stores
        for(const x in this._fileStores) {
            const name = this._fileStores[x];
            //this._config.file(name, name);
            this._config.file({file: name, format: nconf.formats.yaml});
        }
    }
github eclipse / orion.client / modules / orionode / server.js View on Github external
api = require('./lib/api'),
	serverUtil = require('./lib/util/serverUtil');

// Patches the fs module to use graceful-fs instead
require('graceful-fs').gracefulify(fs);

configParams.argv({
	parseValues: true
}).env({
	parseValues: true
});
var configFile = configParams.any("config", "c") || path.join(__dirname, 'orion.conf');
configParams.file({
	parseValues: true,
	file: configFile, 
	format: path.extname(configFile) === ".conf" ? configParams.formats.ini : configParams.formats.json
});

var PORT_LOW = 8082;
var PORT_HIGH = 10082;
var port = configParams.any("port", "p", "PORT") || 8081;

var cluster, clusterParam = configParams.get("orion_cluster");
if (clusterParam) {
	cluster = require('cluster');
}

var homeDir = os.homedir();
if (process.versions.electron) {
	var logPath = path.join(homeDir, '.orion', 'orion.log');
	if(process.platform === 'darwin'){
		logPath = path.join(homeDir, '/Library/Logs/Orion', 'orion.log');
github kaelig / moniteur / bin / moniteur.js View on Github external
nconf.formats.yaml = require('nconf-yaml')
const log = debug('moniteur:log')

program
  .version(require('../package.json').version)

nconf
  .env({
    separator: '__',
    lowerCase: true,
    whitelist: ['REDISCLOUD_URL', 'REDIS_URL', 'DB__REDIS_URL']
  })
  .argv()

if (process.env.NODE_ENV !== 'production') {
  nconf.file('environment', { file: path.join(__dirname, '/../.moniteurrc.development.yml'), format: nconf.formats.yaml })
}
nconf.file('environment', { file: '.moniteurrc.yml', dir: process.cwd(), search: true, format: nconf.formats.yaml })

nconf.defaults(yaml.safeLoad(fs.readFileSync(path.join(__dirname, '/../.moniteurrc.default.yml'), 'utf8')))

nconf
  .set('assets', process.env.ASSETS ? yaml.safeLoad(process.env.ASSETS) : nconf.get('assets'))

// nconf evaluates the : in the protocol as a key:value pair
// so we're restoring the colon in the URL protocols
nconf
  .set('db:redis_url',
    process.env.REDIS_URL ? process.env.REDIS_URL.replace(/redis\/\//, 'redis://')
      : (process.env.REDISCLOUD_URL ? process.env.REDISCLOUD_URL.replace(/redis\/\//, 'redis://')
        : (nconf.get('db:redis_url') ? nconf.get('db:redis_url').replace(/redis\/\//, 'redis://')
          : null)))
github hyperledger / caliper / src / comm / Config.js View on Github external
*
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

//const commUtils = require('./util');
const path = require('path');
const nconf = require('nconf');
nconf.formats.yaml = require('nconf-yaml');

//
// The class representing the hierarchy of configuration settings.
//
const Config = class {
    /**
     * Constructor
     */
    constructor() {
        nconf.use('memory');
        nconf.use('mapenv', {type:'memory'});
        this.mapSettings(nconf.stores.mapenv, process.env);
        this._fileStores = [];
        nconf.argv();
        nconf.env();
        // reference to configuration settings
github hyperledger / caliper / packages / caliper-core / lib / common / config / Config.js View on Github external
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

const fs = require('fs');
const path = require('path');
const nconf = require('nconf');

nconf.formats.yaml = require('nconf-yaml');

const keys = {
    Bind: {
        Sut: 'caliper-bind-sut',
        Sdk: 'caliper-bind-sdk',
        Args: 'caliper-bind-args',
        Cwd: 'caliper-bind-cwd'
    },
    Report: {
        Path: 'caliper-report-path',
        Options: 'caliper-report-options',
        Precision: 'caliper-report-precision',
        Charting: {
            Hue: 'caliper-report-charting-hue',
            Scheme: 'caliper-report-charting-scheme',
            Transparency: 'caliper-report-charting-transparency'
github indexzero / broadway / lib / broadway.js View on Github external
* broadway.js: Top-level include for the broadway module.
 *
 * (C) 2011, Nodejitsu Inc.
 * MIT LICENSE
 *
 */

var path = require('path'),
    utile = require('utile');

var broadway = exports;

broadway.App      = require('./broadway/app').App;
broadway.common   = require('./broadway/common');
broadway.features = require('./broadway/features');
broadway.formats  = require('nconf').formats;
broadway.plugins  = utile.requireDirLazy(path.join(__dirname, 'broadway', 'plugins'));
github hyperledger / caliper / packages / caliper-core / lib / common / config / Config.js View on Github external
function getFileParsingOptions(filename) {
    return { file: filename, logicalSeparator: '-', format: nconf.formats.yaml };
}
github kaelig / moniteur / bin / moniteur.js View on Github external
const debug = require('debug')
const program = require('commander')
const db = require('../lib/db')
const Record = require('../lib/record')
const nconf = require('nconf')
const compression = require('compression')
const express = require('express')
const auth = require('http-auth')
const slashes = require('express-slashes')
const path = require('path')
const lem = require('lem')
const yaml = require('js-yaml')
const fs = require('fs')
nconf.formats.yaml = require('nconf-yaml')
const log = debug('moniteur:log')

program
  .version(require('../package.json').version)

nconf
  .env({
    separator: '__',
    lowerCase: true,
    whitelist: ['REDISCLOUD_URL', 'REDIS_URL', 'DB__REDIS_URL']
  })
  .argv()

if (process.env.NODE_ENV !== 'production') {
  nconf.file('environment', { file: path.join(__dirname, '/../.moniteurrc.development.yml'), format: nconf.formats.yaml })
}

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