Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var nconf = require( "nconf" );
// 1) Look for settings from the environment
nconf.env();
// 2) Recurse up the directory tree looking for a file named "local.json"
nconf.file({ dir: __dirname, file: "local.json", search: true });
// 3) Look for settings in a file specified by an environment variable
if ( process.env.BUTTER_CONFIG_FILE ) {
nconf.file( process.env.BUTTER_CONFIG_FILE );
}
// Load default settings from our config. Don't change this file
nconf.defaults( require( "./default-config.js" ) );
// Check for deprecated configuration options, and patch them to new equivalents if they exist
[
{
old: "server:bindIP"
},
{
old: "server:bindPort",
new: "PORT"
},
{
old: "dirs:appHostname",
new: "APP_HOSTNAME"
}
].forEach(function( pref ) {
if ( nconf.get( pref.old ) ) {
// Ignore webpack custom loaders on server. todo: Reuse index.js config.
ignore: /(\/\.|~$|\.(css|styl))/,
// Hook ensures always fresh server response even for client file change.
hook: true,
},
port: process.env.PORT || 1337,
version: require('../../package').version,
webpackStylesExtensions: ['css', 'less', 'sass', 'scss', 'styl'],
};
// Use above config as a default one
// Multiple other providers are available like loading config from json and more
// Check out nconf docs for fancier examples
nconf.defaults(config);
module.exports = nconf.get();
function setup() {
nconf.argv()
.env()
.file({
file
})
// This is the object that you want to override in your own local config
nconf.defaults({
api: 'https://api.datahub.io',
domain: 'https://datahub.io',
token: '',
email: '',
username: ''
})
}
},
});
nconf.env();
// get value of flags defined by any command-line params
const examples = nconf.get('examples');
// Load the main config
nconf.file(__dirname + '/../config.json');
// only override config file if explicitly mentioned in command-line params
nconf.set('examples:enabled', (examples ? true : nconf.get('examples:enabled')));
// load defaults
const defaults: object = require(__dirname + '/defaults.json');
nconf.defaults(defaults);
nconf.required(['platforms:whitelist', 'platforms:blacklist']);
function defaultEnvParams(host: string, port: string | number, prop: string) {
nconf.set(prop + ':host', host);
nconf.set(prop + ':port', port);
}
defaultEnvParams(
process.env.HOST || nconf.get('service:host'),
process.env.PORT || nconf.get('service:port'),
'service'
);
defaultEnvParams(
process.env.REDIS_HOST || nconf.get('redis:host'),
import * as _ from "lodash";
import * as nconf from "nconf";
import { Env } from "./config.interfaces";
import { ConfigDiToken } from "./config.di";
import { CipherService, CipherDiToken } from "../shared/cipher";
const env = process.env.NODE_ENV || Env.DEVELOPMENT;
nconf.use("memory");
nconf
.defaults(require(`./env/config.default`))
.overrides(require(`./env/config.${env}`))
.argv({
NODE_ENV: {
default: "development",
},
example: {
describe: "Example description for usage generation",
demand: true,
default: "some-value",
parseValues: true,
},
})
.env(["NODE_ENV"]); // set here available env variables to be loaded
export const configProvider = {
const nconf = require('nconf');
const request = require('request-promise');
const getPort = require('get-port');
const { HttpAgent, auth } = require('socksv5');
const { assert } = require('chai');
const _ = require('lodash');
const { TorPool, SOCKSServer } = 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('SOCKSServer', function () {
describe('#handleConnection(socket)', function () {
let socksPort;
let socksServerTorPool;
let socksServer;
before('start up server', async function (){
socksServerTorPool = new TorPool(nconf.get('torPath'), {}, nconf.get('parentDataDirectory'), 'round_robin', null);
socksServer = new SOCKSServer(socksServerTorPool, null, false);
this.timeout(WAIT_FOR_CREATE);
await socksServerTorPool.create(1);
socksPort = await getPort();
function initGlobalConfigs () {
const configFilePath = app.getPath('home') + '/.leptonrc'
logger.info(`[conf] Looking for .leptonrc at ${configFilePath}`)
nconf.argv().env()
try {
nconf.file({ file: configFilePath })
} catch (error) {
logger.error('[.leptonrc] Please correct the mistakes in your configuration file: [%s].\n' + error, configFilePath)
}
nconf.defaults(defaultConfig)
global.conf = nconf
}
var packdb = function packdb() {
//defining a var instead of this (works for variable & function) will create a private definition
var dirty = require("./dirty/dirty"),
query = require("dirty-query").query,
nconf = require("nconf"),
log4js = require('log4js'),
logger = log4js.getLogger('packdb');
var homePath = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
var appHome = homePath+'/.slingxdcc/';
nconf.add('settings', {type: 'file', file: appHome+'config/settings.json'});
nconf.defaults({
"logger": {
"packdb": appHome+"packets.db",
"autocleandb" : true,
"cleandb_Xminutes": 60,
"redundantPercentage": 25,
"removePacketsOlder_Xhours": false
}
});
nconf.set('logger',nconf.get('logger'));
nconf.save();
var packDb = dirty.Dirty(nconf.get('logger:packdb'));
packDb.on('load', function () {
import cli from 'commander';
import nconf from 'nconf';
import os from 'os';
import path from 'path';
import shelljs from 'shelljs';
import { GraphQLClient } from 'graphql-request';
import { prompt } from 'inquirer';
nconf.file(path.join(os.homedir(), '.kommandrrc'));
nconf.defaults({
user: 'anon',
});
const version = '0.0.1';
const graphqlClient = new GraphQLClient('http://localhost:5001/graphql', {
headers: {
authorization: 'token',
'User-agent': `kommandr-cli ${version}`,
username: nconf.get('user'),
token: nconf.get('token'),
}
});
function loadConfig() {
nconf.file({
file: configFile
});
nconf.defaults({
base_dir: __dirname
});
}