* Use, duplication or disclosure restricted by GSA ADP Schedule
 * Contract with IBM Corp.
 */
var 
	async = require('async'),
	nconf = require('nconf'),
    path = require('path'),
    Q = require('q'),
    request = require("request"),
	slackClient = require("../lib/client/slack-client"),
    Slack = require('slack-node'),
    test = require('tape'),
    _ = require('underscore')
;

nconf.env("__");

if (process.env.NODE_ENV) {
    nconf.file('node_env', 'config/' + process.env.NODE_ENV + '.json');
}

// Load in the test information.
nconf.file('testUtils', path.join(__dirname, '..', 'config', 'testUtils.json'));

var defaultHeaders = {
    'Accept': 'application/json,text/json',
    'Content-Type': 'application/json'
};

var mockServiceInstanceId = "tape" + new Date().getTime();
var mockToolchainId = "2e538e2e-b01a-45f1-8a4d-97311ce8ec0b";
Example #2
0
var express = require('express');
var path = require('path');
var favicon = require('static-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var nconf = require('nconf');

var routes = require('./routes/index');
var uber = require('./routes/uber');
var wunderground = require('./routes/wunderground');

var app = express();


nconf.env().argv();
nconf.file('./config.json');

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

app.use(favicon());
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes);
app.use('/api/uber', uber);
Example #3
0
var nconf = require('nconf');
var util = require('util');
var fs = require('fs');

// ### Heirarchical Config, those added first take priority.
// 1. any overrides
nconf.overrides({
	// 'always': 'be this value' 
});


// 2. `process.env`
// to  see all environment variables, just use .env();
nconf.env(['PATH', 'conf']);

// 3. `process.argv`
nconf.argv();

console.log("loading config");

function getUserHome() {
  return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
}

var configFile = getUserHome() + '/.buildblinkrc';

// if(!fs.existsSync(configFile)){
// 	console.error("!!!  No ~/.buildblinkrc file found . . . ");
// }
nconf.file(configFile);
Example #4
0
* 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.
*/

/**
 * Get server settings from settings.json. Some settings, database connection parameters
 * in particular can be overriden by environment variables.
 * 
 * @module settings
 **/

var nconf = require("nconf"),
    configFile = __dirname + "/settings.json";

nconf.env().file(configFile);

module.exports = {
    getHttpPort: function() {
        return nconf.get("http:port");
    },

    isClusteringEnabled: function() {
        var setting = nconf.get("http:enableClustering");
        return setting === true || setting === "true";
    },

    getClusterCount: function() {
        return parseInt(nconf.get("http:clusterCountOverride"), 10);
    },
Example #5
0
module.exports = function loopmocha(grunt) {
	nconf.env()
		.argv();
	// Load task
	grunt.loadNpmTasks('grunt-loop-mocha');
	// Options
	return {
	"src": ["<%=loopmocha.basedir%>/spec/*.js"],
	"basedir": process.cwd() + "/" + "test/functional",
	"options": {
		"mocha": {
			"reportLocation": grunt.option("reportLocation") || "<%=loopmocha.basedir%>/report",
			"timeout": grunt.option("timeout") || 600000,
			"grep": grunt.option("grep") || 0,
			"debug": grunt.option("debug") || 0,
			"reporter": grunt.option("reporter") || "spec"
		},
		"nemoData": {
			"autoBaseDir": "<%=loopmocha.basedir%>",
			"targetBrowser": nconf.get("TARGET_BROWSER") || "firefox",
			"targetServer": nconf.get("TARGET_SERVER") || "localhost",
			"targetBaseUrl": "http://*****:*****@featureGroup1@"
						}
					} ,
					{
						"description": "ci-featuregroup-2",
						"mocha": {
							"grep": "@featureGroup2@"
						}
					},
					{
						"description": "ci-featuregroup-3",
						"mocha": {
							"grep": "@featureGroup3@"
						}
					}
				]
			}
		}
	};
};
'use strict';

var nconf = require('nconf');

// configure nconf
nconf.env().file({
  file: 'config.json'
});

module.exports = nconf;
Example #7
0
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var session = require('express-session');

var routes = require('./routes/index');
var users = require('./routes/users');
var authentication = require('./routes/authentication');

var BnetStrategy = require('passport-bnet').Strategy;
var passport = require('passport');

//NConf

var nconf = require('nconf');
nconf.env().file({file: 'config/private.json'});

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

app.use(favicon());
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(cookieParser());
app.use(require('less-middleware')(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));
Example #8
0
var nconf = require('nconf');
nconf.env().file({file: 'secret.json'});

var request = require('request');
var _ = require('underscore');

module.exports = {
    sendOrder: function (orderInfo, callback) {
        var purchaseOrder = {
            customerName: orderInfo.shipping.name.first + " " + orderInfo.shipping.name.last,
            shippingAddress: orderInfo.shipping.address.address1 + ", " + orderInfo.shipping.address.address2 + ", " + orderInfo.shipping.address.town + ", " + orderInfo.shipping.address.province + ", " + orderInfo.shipping.address.pcd + ", " + orderInfo.shipping.address.country,
            lineItems: []
        };

        _.each(orderInfo.carts, function (value, key, list) {
            purchaseOrder.lineItems.push({
                color: value.color,
                material: value.material,
                quantity: value.quantity,
                status: "NOT_STARTED",
                product: {
                    name: value.name,
                    code: value.code
                }
            });
        });

        request.post({
            uri: nconf.get('oms_uri') + "/eshop",
            json: purchaseOrder,
            auth: {user: nconf.get('oms_username'), password: nconf.get('oms_password')}
Example #9
0
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var routes = require('./routes/index');
// var users = require('./routes/users');

//load more modudles
var nconf          = require('nconf');
var underscore     = require('underscore');
var passport       = require('passport');
var BasicStrategy  = require('passport-http').BasicStrategy;
var bcrypt         = require('bcrypt');
var async          = require('async');

//Load configuration hierarch
nconf.env().argv().file(__dirname + '/settings/config.json');
//start app
var app = express();

// app public path
app.use(express.static(path.join(__dirname, 'app')));


//minimum frontend routing
app.use('/', routes);
// app.use('/users', users);


// app.get('/ping', function(req, res){
//     res.send(200)
// });
Example #10
0
var express = require('express')
  , routes = require('./routes')
  , http = require('http')
  , path = require('path')
  , passport = require('passport')
  , util = require('util')
  , nconf = require('nconf')
  , FacebookStrategy = require('passport-facebook').Strategy;

var app = express();

nconf.env().file({file: 'settings.json'});

app.configure(function(){
  app.set('port', process.env.PORT || 80);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'ejs');
  app.use(express.favicon(__dirname + '/public/favicon.png')); 
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.cookieParser('kararara'));
  app.use(express.session());
  app.use(passport.initialize());
  app.use(passport.session());
  app.use(app.router);
  app.use(express.static(path.join(__dirname, 'public')));
});

app.configure('development', function(){
  app.use(express.errorHandler());
Example #11
0
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var multer  = require('multer');

var routes = require('./routes/index');
var nconf = require('nconf');
var request = require('request');


nconf.env().argv().file('sendMail', {
    file: 'config.json',
    search: true
});

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');


app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json({limit: '5mb'}));
app.use(bodyParser.urlencoded({limit: '5mb', extended: false }));
app.use(cookieParser('SomEse12cretS32tring'));
app.use(express.static(path.join(__dirname, 'public')));
Example #12
0
"use strict";
var express = require('express')
  , app     = express()
  , nconf   = require('nconf')
  , _        = require('underscore');

//Load configuration hierarch
nconf.env().argv().file(__dirname + '/config.json');

var model    = new require('./model')(nconf, _);
var settings = new require('./settings')(nconf, express, app);
var api      = new require('./api')(app, model, _);

// Start listening after everything is loaded
app.listen(nconf.get("port"));
Example #13
0
var nconf = require('nconf');

var filename = 'config.'+ (nconf.env().get("AssetServerEnv") || "local") +'.json';

nconf.file({ file: filename });
module.exports = nconf.get('config');
Example #14
0
import Schema from '../data/schema';
import GraphQLHTTP from 'express-graphql';
import {graphql} from 'graphql';
import {introspectionQuery} from 'graphql/utilities';

import {MongoClient} from 'mongodb';

let app = express();

//*** BEGIN CONFIG SECTION ***
let configFilePath = "./config/configApp.json";
	
//The first config source below has highest priority, with each successive one having lower priority.
nconf.file('custom', configFilePath);
nconf.argv(); //Arguments passed when application started
nconf.env(); //Enviornment variables

//*** END CONFIG SECTION ***

app.use(express.static('public'));

(async () => {
	try {
		let dbConnectUrl = nconf.get("MONGO_URL");
		let db = await MongoClient.connect(dbConnectUrl);
		let schema = Schema(db);
		
		app.use('/graphql', GraphQLHTTP({
			schema,
			graphiql: true
		}));
Example #15
0
'use strict';

const express = require('express');
const bodyParser = require('body-parser');
const jsonParser = bodyParser.json();
const router = express.Router();
const nconf = require('nconf');

nconf.env().argv().file('./conf/serverconf.json');

const dao = require(nconf.get('dao'));

module.exports = router;

// REST END POINTS
// Create
router.post('/students', jsonParser, (req, res) => {
    let student = req.body;

    dao.create(student, function (err, id) {
        if (err) {
            if (err) console.log(`Unable to create student. id: ${id}`.red);
            return res.sendStatus(500);
        }

        res.status(201).json(id);
    });
});

// Read
router.get('/students/:studentId.json', (req, res) => {
Example #16
0
const init = (application_root_folder) => {
    application_root_folder = path.resolve(application_root_folder || path.dirname(require.main.filename));

    let config_folder_path = path.join(application_root_folder, "config");

    app_config
        .env()
        .argv();
    let run_mode = app_config.get("NODE_ENV") || "development";
    let deploy_mode = app_config.get("DEPLOY_MODE") || "development";

    //app_config.defaults({env: {"development": "development", "env": "development"}, NODE_ENV: "development"});

    if (run_mode === "development") {
        app_config.file("development", path.join(config_folder_path, "/development.json"));
        app_config.set("env:development", "development");
        app_config.set("env:env", "development");
    } else if (run_mode === "production") {
        if (deploy_mode === "staging") {
            app_config.file("staging", path.join(config_folder_path, "staging.json"));
            app_config.set("env:staging", "staging");
            app_config.set("env:env", "staging");
        } else {
            deploy_mode = "production";
            app_config.set("env:production", "production");
            app_config.set("env:env", "production");
        }

        app_config.set("env:development", null);
    }

    app_config.file("live", path.join(config_folder_path, "config.json"));

    /**
     *
     */

    logger = logger_factory.getLogger(
        "APPConfig", run_mode === "production"
        ? "WARN"
        : "DEBUG");

    logger.info("APP configuration init in progress ....");

    let liveEmulation = app_config.get("LIVE_EMULATION") || "";
    liveEmulation = (liveEmulation == "true");
    app_config.set("liveEmulation", liveEmulation);

    logger.info("APP run_mode is: " + run_mode + " APP deploy_mode is: " + deploy_mode);
    app_config.set("run_mode", run_mode);
    app_config.set("env:" + run_mode, run_mode);
    app_config.set("deploy_mode", deploy_mode);
    app_config.set("env:" + deploy_mode, deploy_mode);

    app_config.set("hostname", os.hostname());
    app_config.set("application_root_folder", application_root_folder);

    if (app_config.get("env:development")) {
        logger.info("Backing stage hostname: ", app_config.get("topos:host"));
        let backingStage = app_config.get("topos:host") || ";";
        app_config.set("backing-stage", backingStage);
    }

    config_initialized = true;
    logger.info("APP configuration init completed.");

};
Example #17
0
var nconf = require('nconf')
  , uuid = require('node-uuid')
  , azure = require('azure');

nconf.env().file({ file: 'config.json'});

var tableName = nconf.get("TABLE_NAME")
  , partitionKey = nconf.get("PARTITION_KEY")
  , accountName = nconf.get("STORAGE_NAME")
  , accountKey = nconf.get("STORAGE_KEY");

var tableService = azure.createTableService(accountName, accountKey);

exports.list = function (req, res) {
	var table = req.route.params.table

	tableService.createTableIfNotExists(table, function(error){
		if(!error){
			var query = azure.TableQuery
				.select()
				.from(table);

			tableService.queryEntities(query, function (error, entities) {
				if (!error) {
					res.json(entities);
				}
			});
		}
  });
}
Example #18
0
var getLogPath = function(path) {
  if (path.substring(0,1) == "~") {
    var home = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
    path = home + path.substring(1, path.length - 1);
  }
  return path;
};

// NOTE: use this script to create an nconf compatible settings file.  It will create (or overwrite/update) a file called nconf.json in the same folder as this script.
var fs        = require('fs'),
    nconf     = require('nconf'),
    path      = require('path'),
    pkg       = JSON.parse(fs.readFileSync('package.json', 'utf8'));

nconf.env().argv(); //load environment settings and args

//load user settings first, if file exists
var userFile = path.join(__dirname, 'settings-user.json');
if (fs.existsSync(userFile)) {
  console.log('user settings:', userFile);
  nconf.add('user', { type: 'file', file: userFile });  
}

//determine which settings file to apply
var key = "development"; // "development" is the default if an environment is not determined to have been supplied

//priority 1: was an argument passed while starting up node?  e.g. node server.js staging
if (process.argv[2]) {
  key = process.argv[2].toLowerCase();
}
//priority 2: match on "env" in user-settings.js
Example #19
0
// There are defined in common.js as well, but that is not available without
// transpilation, which is not done for webpack configuration file
const path = require('path');
const ROOT = path.resolve(__dirname, '../..');
const SRC = path.resolve(ROOT, 'src');
const common = {
    paths: {
        ROOT,
        SRC
    }
}

const jsonConfigKeys = ["api_base", "local_storage_user_expiry_time", "nocache", "raven_id", "commit_hash"];
const templateConfigKeys = ["LE_PRODUCTION_INSTANCE", "APP_MODE"];

nconf.env(jsonConfigKeys.concat(templateConfigKeys));
nconf.defaults({
    'LE_PRODUCTION_INSTANCE': '#',
    'APP_MODE': 'production',
});
// 'memory' is needed to store the commit_hash
nconf.use('memory')
nconf.set('commit_hash', new GitRevisionPlugin().commithash());
nconf.required(jsonConfigKeys.concat(templateConfigKeys));

const indexTemplate = jade.compileFile(path.join(common.paths.SRC, 'index.jade'), { pretty: true })

// We only want a subset of the read variables in configJson passed
// to template. Nconf only allows for fetching one variable or all
var configJson = {};
for (var key of jsonConfigKeys) {
Example #20
0
var nconf = require('nconf');

nconf
    .env(['NODE_ENV', 'PORT', 'SESSION_SECRET'])
    .file({
        file: 'app.config.json'
    })
    .defaults({
        PORT: 3000,
        SESSION_SECRET: 'tp-views-utils-default-session-secret'
    });

module.exports = {
    nconf
};
Example #21
0
#!/usr/bin/env node
var bunyan = require('bunyan')
var bunyanFormat = require('bunyan-format')
var nconf = require('nconf')
var Server = require('../api/server')
var http = require('http')
var url = require('url')

nconf.env({
  separator: '_'
}).argv()
nconf.defaults(require('../defaults'))

var logger = bunyan.createLogger({
  name: nconf.get('appname'),
  level: nconf.get('log:level'),
  stream: bunyanFormat({
    outputMode: nconf.get('log:format')
  })
})

var mhttp = require('http-measuring-client').create()
mhttp.mixin(http)
mhttp.on('stat', function (parsed, stats) {
  logger.info({
    parsedUri: parsed,
    stats: stats
  }, '%s %s took %dms (%d)', stats.method || 'GET', url.format(parsed), stats.totalTime, stats.statusCode)
})

var server = new Server({
Example #22
0
var join = require('path').join
var fs = require('fs')
var nconf = require('nconf')

if (!fs.existsSync(__dirname + '/config.json')) {
  throw new Error('Missing config.json')
}

nconf
.env({
  match: /^DB:|STEAM:/,
  whitelist: ['PORT', 'SESSION:SECRET', 'NODE_ENV', 'SQUAD_XML']
})
.file('config.json')
.defaults({NODE_ENV: 'development'})

// Let babel register from here on
require('babel/register', {
  sourceMaps: 'inline'
})

// Load all models first, must be done due to babel
fs.readdirSync(join(__dirname, 'server/models')).forEach(function (file) {
  if (~file.indexOf('.js')) require(join(__dirname, 'server/models', file))
})

// Generate user contributed markdown guides
require('./server/utils/generate-contrib-markdown')

// start server
require('./server')
Example #23
0
var express = require('express');
var http = require('http');
var app = express();
var server = http.createServer(app);
var nconf = require('nconf');

nconf.env(['PORT'])
    .file({file: 'config.json'});

nconf.defaults({
    'PORT': '5000'
});

port = nconf.get('PORT');

app.use(express.static(__dirname + '/app'));
app.set('appDir', __dirname);

require('./src/home/homeController')(app);
require('./src/league/leagueController')(app);
require('./src/calendar/calendarController')(app);
require('./src/test/testController')(app);
require('./src/populate/populateController')(app);


server.listen(port);
console.log('server listening on port ' + port);
Example #24
0
  process.exit(1);
}

// the scrubLogs is a list of fields we do not want to
// console log in verbose mode i.e. username and passwords to database, etc.
program.scrubLogs = new RegExp(config.scrubLogs || commonConfig.scrubLogs ||
  program.scrubLogs || '\s(user|pass|aws_)\w*\s+.+$','igm');

// the envWhiteList is a list of environment variable
// we will load into the config link NODE_ENV
var envWhiteList = (config.envWhitelist || commonConfig.envWhitelist ||
  program.envWhitelist || 'NODE_ENV,PELLET_CONF_DIR').split(',');

// now build up the configuration starting with environment variable
// then override with the common config and environment config (i.e. dev vs prod)
nconf.env({separator: '__', whitelist:envWhiteList});
nconf.use('memory').merge(commonConfig);
nconf.use('memory').merge(config);

// merge in the local config to override our config
if(localConfig) {
  nconf.use('memory').merge(localConfig);
}

// overwrite configuration with argument passed in
utils.overwriteNconfWithArgs(nconf, program);

// show help and exit (no commands qued)
if(readyQue.length == 0) {
  program.help();
}
Example #25
0
// www.andrewsouthpaw.com/2015/02/08/environment-variables/
import nconf from 'nconf';

// Use less-terrible separator character, stackoverflow.com/questions/25017495
nconf.env('__');

// For local development with secrets. Check src/common/_secrets.json file.
// nconf.file('src/common/secrets.json');

// Remember, never put secrets in default config.
// Use environment variables for production, and secrets.json for development.
nconf.defaults({
  appName: require('../../package.json').name,
  // Use appVersion defined in gulp env task or Heroku dyno metadata.
  appVersion: process.env.appVersion || process.env.HEROKU_SLUG_COMMIT,
  defaultLocale: 'en',
  firebaseUrl: 'https://este.firebaseio.com',
  googleAnalyticsId: 'UA-XXXXXXX-X',
  isProduction: process.env.NODE_ENV === 'production',
  locales: ['cs', 'de', 'en', 'es', 'fr', 'pt', 'ro'],
  port: process.env.PORT || 8000,
  sentryUrl: 'https://f297cec9c9654088b8ccf1ea9136c458@app.getsentry.com/77415',
});

export default nconf.get();
var mocha = require('mocha');
var assert = require('assert');
var nconf = require('nconf');
var testingKeys = nconf.env().file({
    file: __dirname + '/../testing_keys.json'
});
var util = require('util');
var merge = require('merge');

var postmark = require('../lib/postmark/index.js');

describe('client template handling', function() {
    this.timeout(10000);
    var _client = null;

    beforeEach(function() {
        _client = new postmark.Client(testingKeys.get('WRITE_TEST_SERVER_TOKEN'));
    });

    after(function() {
        _client.getTemplates(function(err, results) {

            while (results.Templates.length > 0) {
                var t = results.Templates.pop();
                if (/testing-template-node-js/.test(t.Name)) {
                    _client.deleteTemplate(t.TemplateId);
                }
            }
        });
    });
Example #27
0
import nconf from 'nconf';

let conf = nconf
  .env({
    separator: '__',
    lowerCase: true,
  });

if (!process.env.APEX_FUNCTION_NAME) {
  conf = conf.file(process.env.FR_CONFIG_FILE || 'config.json');
}

const defaultConfig = {
  port: 3000,
  github: {
    // Public github
    base_url: 'https://api.github.com/',
  },
  review: {
    // Default configs for all reviews
    defaults: {
      approval_comment_regex: '(\\bLGTM\\b|:\\+1:|:shipit:)',
      approval_comment_regex_options: 'i',
      do_not_merge_title_regex: '\\b(wip|do not merge|dnm)\\b',
      do_not_merge_title_regex_options: 'i',
    },

    // Off by default
    dynamodb_sign_off: false,
    repo_collaborators_sign_off: false,
Example #28
0
// For testing purposes.
function reset() {
  userDefinedOptions = {};
  nconf.env();
}
var User = require('./database/models/user.model.js');
var Tag = require('./database/models/tag.model.js');
var session = require('express-session');
var mongoStore = require('connect-mongo')(session);
var basicAuth = require('basic-auth');
var mongoose = require('mongoose');
var secret = 'Base-Secret';
var azure = require('azure-storage');
var fs = require('fs');
var _ = require('lodash');
var expressJwt = require('express-jwt');
var jwt = require('jsonwebtoken');
var secret = "it's a secret to everybody";

var nconf = require('nconf');
nconf.env()
     .file({ file: 'config.json'});
var tableName = nconf.get("TABLE_NAME");
var partitionKey = nconf.get("PARTITION_KEY");
var accountName = nconf.get("STORAGE_NAME");
var accountKey = nconf.get("STORAGE_KEY");
var blobSvc = azure.createBlobService(accountName, accountKey), tableName, partitionKey;


//handler has all database methods exported
//check './request-handler' for the methods used below
var handler = require('./request-handler')


module.exports = function(app) {
Example #30
0
 after(function() {
   process.env.skip_location_event_interval = actualInterval;
   nconf.env().file({ file: './config.json' });
 });