Example #1
0
function loadConfig() {
	nconf.file({
		file: configFile
	});

	nconf.defaults({
		base_dir: __dirname,
		themes_path: path.join(__dirname, 'node_modules'),
		views_dir: path.join(__dirname, 'public/templates'),
		version: pkg.version
	});

	if (!nconf.get('isCluster')) {
		nconf.set('isPrimary', 'true');
		nconf.set('isCluster', 'false');
	}

	// Ensure themes_path is a full filepath
	nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path')));
	nconf.set('core_templates_path', path.join(__dirname, 'src/views'));
	nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-vanilla/templates'));

	if (!process.send) {
		// If run using `node app`, log GNU copyright info along with server info
		winston.info('NodeBB v' + nconf.get('version') + ' Copyright (C) 2013-2014 NodeBB Inc.');
		winston.info('This program comes with ABSOLUTELY NO WARRANTY.');
		winston.info('This is free software, and you are welcome to redistribute it under certain conditions.');
		winston.info('');
	}
}
function createConfiguration() {
// create an nconf object, and initialize it with given values from
// the environment variables and/or from the command line
  nconf.argv().env();
  nconf.file('mongo', './config/mongo-config.json');
  nconf.file('sympa', './config/sympa-config.json');
  nconf.file('server', './config/server-config.json');
  nconf.file('filebrowser', './config/filebrowser-config.json');
  nconf.file('authentication', './config/authentication-config.json');
  nconf.defaults({
    port: '17124',
    mongoHost: 'localhost',
    mongoPort: '27017',
    publicUrlPrefix: "http://localhost:17124",
    adminURLPattern: "/administration/|/new|/edit|/submit",
    securedByLoginURLPattern: "/members|/groups/(subscribe|unsubscribe)/",
    secret: "secret",
    filebrowser: {
      root: "./test/filebrowser-testfiles"
    },
    beans: new beans('./config/beans.json')
  });

  return nconf;
}
  beforeEach(function (done) {
    nconf.defaults({
      port: '3000',
      test: true,
      scriptConcurrency: 20,
      max_notifications: 100,
      log_directory: './log',
      log_level: 'info', // error, warn, info, verbose, debug, silly
      mkls_poll_delay: 1000,
      mkls_cmd: 'nc localhost 6557',
      long_poll_timeout: 0,
      operation_timeout: 10,
      error_lock_time: 10,
      db_path: ''
    });

    testBackend = new _testBackend2.default(nconf, logger);
    testBackend.load(testCfgB);

    stationManager = new _stationManager2.default(nconf, logger, testBackend.getHilbertCLIConnector(), testBackend.getMKLivestatusConnector());

    stationManager.init().then(function () {
      return stationManager.startStations(['station_a', 'station_b', 'station_c']);
    }).then(function () {
      return stationManager.pollMKLivestatus();
    }).then(function () {
      return stationManager.pollMKLivestatus();
    }).then(function () {
      var httpAPIServer = new _httpApiServer2.default(stationManager, nconf, logger);
      httpAPIServer.init().then(function () {
        apiServer = httpAPIServer.getServer();
        done();
      });
    });
  });
Example #4
0
var configure = function(){
    //order of hiearchy: 1. command line args, 2. environment vars, 3. file 
    nconf.argv()
        .env();

    //Set defaults. These are overwritten by contents of file
    nconf.defaults({
        //If NODE_ENV isn't provided, use a default
        //  NODE_ENV can be one of 'local', 'develop', 'staging', 'production', 
        //      or 'test'
        NODE_ENV: 'local'
    });

    //File is located in `conf/environment.json` where environment is NODE_ENV
    var env = nconf.get('NODE_ENV');
    if(env === 'localhost'){ env = 'local'; }
    var configFile = __dirname + '/' + env + '.json';

    //Load corresponding file
    nconf.file({ file: configFile });
    nconf.file('secrets', __dirname + '/secrets.json');

    // Make sure secrets exists / has data
    if(_.keys(nconf.stores.secrets.store).length < 1){
        winston.error('conf/secrets.json NOT found! Copy conf/secrets.example.json to conf/secrets.json and modify secrets');
        throw new Error('secrets.json not found! Copy conf/secrets.example.json to conf/secrets.json. View README for setup instructions');
    }

};
(function loadConfigData() {
  // TODO: document the config example, first the env example. i.e.: server__port=3000
  nconf
    .argv({
      config: {
        alias: ['config-path', 'configPath', 'c']
      }
    })
    .env('__');

  nconf.defaults({
    config: nconf.get('config') || nconf.get('CONFIG_PATH') || nconf.get('CONFIG') || path.resolve(__dirname, '..', 'config', 'default.yml')
  });

  nconf.file({
    file: nconf.get('config'),
    format: {
      stringify: function stringify(obj, options) {
        return yaml.safeDump(obj, options);
      },

      parse: function parse(obj, options) {
        return yaml.safeLoad(obj, options);
      }
    }
  });
})();
Example #6
0
function initConfig(cb)
{
  startupLogger.info("Initiating configuration..");
  nconf.file({ file: 'config.json' });

  nconf.defaults({
      'http': {
          'ip': "0.0.0.0",
          'port': 8080
      }
  });

  pageurl = nconf.get("pageurl");
  // add '/' at the end of pageurl if needed
  if(pageurl.charAt(pageurl.length - 1) != '/')
    pageurl += '/';

  sessionSecret = nconf.get("sessionSecret");
  if(!sessionSecret || sessionSecret.length == 0)
  {
    cb("No session-secret given in config.json");
  }
  else
  {
    cb();
  }
}
exports.register = () => {
  const rootPath = path.join(__dirname, '../');
  const configFile = 'config.json';

  // 1. any overrides
  nconf.overrides({});

  // 2. process.env
  // 3. process.argv
  nconf.env()
    .argv();

  // 4. Values in config.json
  nconf.file(rootPath + configFile);

  // 5. Any default values
  nconf.defaults({
    application: {
      port: 3100
    }
  });

  // Log current configuration
  winston.info('app - config: logging: ', nconf.get('logging'));
  winston.info('app - config: config file loaded from: ', rootPath + configFile);
  winston.info('app - config: application:', nconf.get('application'));

  winston.info('app - config: nconf loaded');
};
module.exports = Webtask.fromExpress(function(req, res) {
  nconf
    .defaults({
      AUTHORIZE_API_KEY: req.webtaskContext.secrets.EXTENSION_SECRET,
      AUTH0_DOMAIN: req.webtaskContext.secrets.AUTH0_DOMAIN,
      AUTH0_CLIENT_ID: req.webtaskContext.secrets.AUTH0_CLIENT_ID,
      AUTH0_CLIENT_SECRET: req.webtaskContext.secrets.AUTH0_CLIENT_SECRET,
      EXTENSION_SECRET: req.webtaskContext.secrets.EXTENSION_SECRET,
      DATA_CACHE_MAX_AGE: 1000 * 30,
      NODE_ENV: 'production',
      HOSTING_ENV: 'webtask',
      CLIENT_VERSION: process.env.CLIENT_VERSION,
      USE_OAUTH2: true,
      WT_URL: req.webtaskContext.secrets.WT_URL
    });

  const StorageProviders = require('./srv/server/lib/storage/providers');
  const initServer = require('./srv/server');
  const app = initServer({
    storageProvider: new StorageProviders.WebtaskStorageProvider({
      storageContext: req.webtaskContext.storage
    })
  });

  return require('./src/server/index.js')(req, res);
});
Example #9
0
module.exports = function(serviceName, defaults) {
  'use strict';

  if (!serviceName || typeof serviceName !== 'string') {
    throw new Error('serviceName is a required string');
  }

  if (!defaults) {
    defaults = {};
  }

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

  var configPath = process.env.NPM_CONF_PATH;
  if (!configPath) {
    Object.defineProperty(nconf, 'warning', { value: new Array(1) });
    nconf.warning[0] = 'NPM_CONF_PATH not set';
  }

  if (configPath) {
    var configFile = serviceName + '.json';

    // Service config values
    var envConfig = path.join(configPath, configFile);
    if (fs.existsSync(envConfig)) {
      nconf.file(envConfig);
    }
  }

  nconf.defaults(defaults);

  return nconf;
};
function createConfiguration() {
  nconf.defaults({
    mongoHost: 'localhost',
    mongoPort: '27017',
    mongoDB: 'swk-spa'
  });
  return nconf;
}
Example #11
0
Config.prototype.init = function (tugboatDir) {
    store.setDir(tugboatDir);
    this.file();

    nconf.defaults(this._defaults);

    return this;
};
function createConfiguration() {
  nconf.defaults({
    mongoHost: 'localhost',
    mongoPort: '27017',
    beans: new Beans('./config/beans.json')
  });
  return nconf;
}
Example #13
0
function loadConfig() {
  nconf.file({
      file: path.join(__dirname, '/config.json')
  });

  nconf.defaults({
      base_dir: __dirname
  });
}
Example #14
0
function loadConfig() {
	
	console.log("Loading configuration");
	nconf.argv()
		 .file( { file: path.join(__dirname, 'config.json') } );
	nconf.defaults(defaults);
	global.settings = nconf;
	return global.settings;
}
Example #15
0
module.exports = function() {
  nconf.argv().env();
  nconf.file({ file: './config.json' });

  nconf.defaults({
    API_KEY: 'RGAPI-539a258f-8922-41b2-8aad-d4786a252381'
  });
  return nconf;
};
 beforeEach(function() {
     // setting environment variable overrides manually through nconf.
     nconf.defaults({
         "OPENSHIFT_POSTGRESQL_DB_HOST": "host2",
         "OPENSHIFT_POSTGRESQL_DB_PORT": 5678,
         "OPENSHIFT_POSTGRESQL_DB_USERNAME": "******",
         "OPENSHIFT_POSTGRESQL_DB_PASSWORD": "******",
         "PGDATABASE": "db2"
     });
 });
Example #17
0
(function () {
    "use strict";

    var express = require('express'),
        nconf   = require('nconf'),
        path    = require('path'),

        routes  = require('./routes/index'),

        app     = express();

    // Provide config defaults.
    nconf.defaults({
        // TODO: Store these as options objects instead.
        'facebook': {
            'authEndpoint':     'https://www.facebook.com/dialog/oauth',
            'tokenEndpoint':    'https://graph.facebook.com/oauth/access_token',
            'userInfoEndpoint': 'https://graph.facebook.com/v2.2/me',
            'redirectPath':     '/redirect/facebook',
            'scope':            'public_profile email'
        },
        'google': {
            'authEndpoint':     'https://accounts.google.com/o/oauth2/auth',
            'tokenEndpoint':    'https://www.googleapis.com/oauth2/v3/token',
            'userInfoEndpoint': 'https://www.googleapis.com/plus/v1/people/me',
            'redirectPath':     '/redirect/google',
            'scope':            'profile email'
        },
        'linkedin': {
            'authEndpoint':     'https://www.linkedin.com/uas/oauth2/authorization',
            'tokenEndpoint':    'https://www.linkedin.com/uas/oauth2/accessToken',
            'userInfoEndpoint': 'https://api.linkedin.com/v1/people/~:(id,email-address,formatted-name)?format=json',
            'redirectPath':     '/redirect/linkedin',
            'scope':            'r_basicprofile r_emailaddress'
        }
    });

    // Load config from the settings file.
    nconf.file('config.json');

    // Set up the view engine.
    app.set('views', path.join(__dirname, 'views'));
    app.set('view engine', 'hjs');

    // Set up the routes.
    app.use('/', routes);

    // Serve static files from the 'public' directory as a fallback.
    app.use(express.static(path.join(__dirname, 'public')));

    app.listen(nconf.get('port'));
    console.log('Express started on ' + nconf.get('hostname') + ':' + nconf.get('port'));

    module.exports = app;
}());
Example #18
0
function loadConfig() {
	nconf.file({
		file: configFile
	});

	nconf.defaults({
		themes_path: path.join(__dirname, 'node_modules')
	});

	// Ensure themes_path is a full filepath
	nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path')));
}
Example #19
0
function initializeConfigDefaults() {
    var defaults = (function () {
        var d = {};
        for (var option in options) {
            if(options.hasOwnProperty(option) && options[option]["default"]) {
                d[option] = options[option]["default"];
            }
        }

        return d;
    }());

    config.defaults(defaults);
}
Example #20
0
function loadConfig() {
	nconf.file({
		file: configFile
	});

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

	// Ensure themes_path is a full filepath
	nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path')));
}
Example #21
0
module.exports = function (done) {
  config.env(['HOST', 'PORT', 'SOCKET_PORT', 'MONGODB']);
  config.defaults({
    HOST: '0.0.0.0',
    PORT: 3000,
    SOCKET_PORT: 8000,
    MONGODB: '0.0.0.0/just-chat',
    SMSSENDER_CREDENTIALS: 'qwerty:qwerty',
    UPLOAD_DIR: './public/uploads',
    SECRET: 'keyboardragon',
    CREDENTIALS: 'basic:auth',
    SMS_MESSAGE: '%n — код для входа в ПростоЧат.'
  });
  done();
};
Example #22
0
File: gcr.js Project: evanlucas/gcr
 mkdirp(gcr.root, function(err) {
   log.resume()
   if (err) {
     err.heading = '[mkdirp]'
     return cb(err)
   }
   nconf.file({ file: confFile })
   nconf.defaults(require('./config.default')(opts))
   if (opts.url) {
     nconf.set('url', opts.url)
   }
   if (opts.token) {
     nconf.set('token', opts.token)
   }
   if (opts.buildDir) {
     nconf.set('buildDir', opts.buildDir)
   }
   if (opts.npm) {
     nconf.set('npm', opts.npm)
   }
   if (opts.hasOwnProperty('strictSSL')) {
     nconf.set('strictSSL', opts.strictSSL)
   }
   if (opts.timeout) {
     nconf.set('timeout', opts.timeout)
   }
   if (!nconf.get('buildDir')) {
     nconf.set('buildDir', '/tmp/builds')
   }
   if (opts.keypath) {
     nconf.set('keypath', opts.keypath)
   }
   if (opts.sslcert) {
     nconf.set('sslcert', opts.sslcert)
   }
   if (opts.sslkey) {
     nconf.set('sslkey', opts.sslkey)
   }
   if (opts.cacert) {
     nconf.set('cacert', opts.cacert)
   }
   gcr.config = nconf
   chain([
       validateGit
     , validateSetup
     , saveConfig
   ], cb)
 })
Example #23
0
function initialize() {
    nconf.file({
        file: 'settings.json'
    });
    nconf.defaults({
        token: '',
        orgs: {},
        github_host: 'github.com',
        github_api_host: 'api.github.com',
        github_api_path: '',
        ignore_repos: [],
        ignore_events: [],
        daemon: false,
        pid: process.pid
    });
}
function createConfiguration() {
  nconf.argv().env();
  nconf.defaults({
    adminListName: "admins",
    port: '17124',
    mongoHost: 'localhost',
    mongoPort: '27017',
    mongoDB: 'swk-spa',
    publicUrlPrefix: 'http://localhost:17124',
    securedByLoginURLPattern: '/members',
    secret: 'secret',
    beans: new Beans('./config/beans.json')
  });

  return nconf;
}
Example #25
0
function createConfiguration() {
// create an nconf object, and initialize it with given values from
// the environment variables and/or from the command line
  nconf.argv().env();
  var configdir = '../config/';
  nconf.file('mongo', configdir + 'mongo-config.json');
  nconf.file('sympa', configdir + 'sympa-config.json');
  nconf.file('server', configdir + 'server-config.json');
  nconf.file('authentication', configdir + 'authentication-config.json');
  nconf.file('mail', configdir + 'mailsender-config.json');
  nconf.file('wiki', configdir + 'wikirepo-config.json');
  nconf.file('activityresults', configdir + 'activityresults-config.json');
  nconf.file('crossite', configdir + 'crosssite-config.json');
  nconf.defaults({
    adminListName: 'admins',
    port: '17124',
    mongoURL: 'mongodb://localhost:27017/swk',
    publicUrlPrefix: 'http://localhost:17124',
    securedByLoginURLPattern:
      '/activityresults|' +
      '/gallery|' +
      '/mailsender|' +
      '/members|' +
      '/new|' +
      '/edit|' +
      '/submit|' +
      '(subscribe|unsubscribe)/|' +
      '/mailarchive|' +
      '/invitation|' +
      '/addToWaitinglist|' +
      '/removeFromWaitinglist|' +
      '/addon|' +
      '/submitAddon|' +
      '/wiki/socrates.*/|' +
      '/payment|' +
      'dashboard',
    secret: 'secret',
    sessionkey: 'softwerkskammer.org',
    beans: new Beans(configdir + 'beans.json'),
    emaildomainname: 'localhost',
    softwerkskammerURL: 'http://localhost:17124',
    socratesURL: 'http://localhost:17224',
    jwt_secret: 'my_very_secret'
  });

  return nconf;
}
Example #26
0
File: app.js Project: Jdesk/NodeBB
function loadConfig(callback) {
	winston.verbose('* using configuration stored in: %s', configFile);

	nconf.file({
		file: configFile,
	});

	nconf.defaults({
		base_dir: __dirname,
		themes_path: path.join(__dirname, 'node_modules'),
		upload_path: 'public/uploads',
		views_dir: path.join(__dirname, 'build/public/templates'),
		version: pkg.version,
	});

	if (!nconf.get('isCluster')) {
		nconf.set('isPrimary', 'true');
		nconf.set('isCluster', 'false');
	}

	// Ensure themes_path is a full filepath
	nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path')));
	nconf.set('core_templates_path', path.join(__dirname, 'src/views'));
	nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-persona/templates'));

	nconf.set('upload_path', path.resolve(nconf.get('base_dir'), nconf.get('upload_path')));

	if (nconf.get('url')) {
		nconf.set('url_parsed', url.parse(nconf.get('url')));
	}

	// Explicitly cast 'jobsDisabled' as Bool
	var castAsBool = ['jobsDisabled'];
	nconf.stores.env.readOnly = false;
	castAsBool.forEach(function (prop) {
		var value = nconf.get(prop);
		if (value) {
			nconf.set(prop, typeof value === 'boolean' ? value : String(value).toLowerCase() === 'true');
		}
	});
	nconf.stores.env.readOnly = true;

	if (typeof callback === 'function') {
		callback();
	}
}
Example #27
0
function getConfiguration() {
  var nconf = require("nconf");

  nconf.use("memory");

  nconf.argv();
  nconf.env();
  nconf.defaults({
    "http": {
      requestTimeoutMSec: 25000,
      port: process.env.PORT || 3000,
      secret: "" // secret for cookies/session
    }
  });

  return nconf;
}
Example #28
0
(function(){
	var nconf = require('nconf'),
		path = require('path'),
		async = require('async'),
		cluster = require('cluster');
	var server = require('./worker');

	global.env = process.env.NODE_ENV || 'production';

	nconf.argv().env();
	nconf.file('default', path.join('config', path.sep, global.env + '.json'));
	nconf.set('base_dir', __dirname);
	nconf.set('client_dir', path.join(nconf.get('base_dir'), path.sep, 'client'));
	nconf.defaults({
		'server': {
			'port': 3000,
			'cluster': false
		},
		'site': {
			'name': 'Seriesbox',
			'use_csrf': true
		}
	});

	global.nconf = nconf;

	// Count the machine's CPUs
	var cpuCount = require('os').cpus().length;

	if(cluster.isMaster && nconf.get('server:cluster')){
		// Create a worker for each CPU
		for(var i = 0; i <cpuCount; i += 1){
			cluster.fork();
		}

		// Restart dead workers
		cluster.on('exit', function(worker){
			console.log('Worker ' + worker.id + ' died :(');
			cluster.fork();
		});

		console.log('Master process started');
	}else{
		server(nconf.get('server:port'));
	}
}());
Example #29
0
File: app.js Project: Ribesg/NodeBB
function loadConfig() {
	nconf.file({
		file: configFile
	});

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

	// Ensure themes_path is a full filepath
	nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path')));
	nconf.set('core_templates_path', path.join(__dirname, 'src/views'));
	nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-vanilla/templates'));
}
  beforeEach((done) => {
    nconf.defaults({
      port: '3000',
      test: true,
      scriptConcurrency: 20,
      max_notifications: 100,
      log_directory: './log',
      log_level: 'info', // error, warn, info, verbose, debug, silly
      mkls_poll_delay: 1000,
      mkls_cmd: 'nc localhost 6557',
      long_poll_timeout: 0,
      operation_timeout: 10,
      error_lock_time: 10,
      db_path: '',
    });

    const testBackend = new TestBackend(nconf, logger);
    testBackend.load(testCfgA);

    stationManager = new StationManager(
      nconf,
      logger,
      testBackend.getHilbertCLIConnector(),
      testBackend.getMKLivestatusConnector()
    );

    stationManager.init().then(() => {
      apiServer = new HttpAPIServer(stationManager, nconf, logger);
      apiServer.init().then(() => {
        httpServer = apiServer.getServer();

        pollWaited = false;
        pollTimedOut = false;

        apiServer.events.on('longPollWait', () => {
          pollWaited = true;
        });

        apiServer.events.on('longPollTimeout', () => {
          pollTimedOut = true;
        });

        done();
      });
    });
  });