Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function main() {
// Load config settings
nconf
.argv({ f: { alias: 'config', describe: 'configuration file' } })
.env();
if (nconf.get('help'))
return console.log('Usage: gitdeploy [-f config.json]');
if (nconf.get('config'))
nconf.file('system', nconf.get('config'));
nconf
.file('user', __dirname + '/config.local.json')
.file('base', __dirname + '/config.json');
// Setup console logging
log.loggers.options.transports = [];
log.remove(log.transports.Console);
var logger = log.add(log.transports.Console, { level: nconf.get('log_level'),
colorize: true, timestamp: utils.shortDate });
log.loggers.options.transports.push(logger.transports.console);
// Make sure we have permission to bind to the requested port
if (nconf.get('web_port') < 1024 && process.getuid() !== 0)
throw new Error('Binding to ports less than 1024 requires root privileges');
var app = module.exports = express();
var server = require('http').createServer(app);
var nconf = require('nconf')
var request = require('request')
// load config
nconf.file({ file: 'config.json' }).env()
// twitter authentication
var twitter_oauth = {
consumer_key: nconf.get('TWITTER_CONSUMER_KEY'),
consumer_secret: nconf.get('TWITTER_CONSUMER_SECRET'),
token: nconf.get('TWITTER_ACCESS_TOKEN'),
token_secret: nconf.get('TWITTER_ACCESS_TOKEN_SECRET')
}
var WEBHOOK_URL = 'https://your-webhook-url'
// request options
var request_options = {
url: 'https://api.twitter.com/1.1/account_activity/webhooks.json',
oauth: twitter_oauth,
process: function(job, done) {
var Promise = require('bluebird'),
db = require('./server/db'),
core = require('../cores/index'),
winston = require('winston'),
path = require('path'),
seekrits = require('nconf')
.file('custom', path.join(process.cwd(), 'server/config/local.env.json'))
.file('default', path.join(process.cwd(), 'server/config/local.env.sample.json')),
mailer = require('../mailer/mailer'),
gameID = job.data.gameID,
// judgePath = path.join(seekrits.get('judgePath'), 'diplomacy-godip'),
variant,
game,
phase;
winston.log('Starting adjudication job', { gameID: gameID });
db.bookshelf.transaction(function(t) {
core.game.getAsync(gameID, t) // Fetches the game in question.
.then(function(_game) {
game = _game;
variant = core.variant.get(game.get('variant'));
Config.prototype.init = function() {
nconf.file('local', file.configFile())
.add('global', {type: 'literal', store: DEFAULT_CONFIG})
.defaults({});
const cfg = nconf.get();
nconf.remove('local');
nconf.remove('global');
// HACK: remove old style configs
for (let x in cfg) {
if (x === x.toUpperCase()) delete cfg[x];
}
delete DEFAULT_CONFIG.type;
delete cfg.type;
_.extendOwn(this, cfg);
};
// Load the configuration-values
// user specified config override
if (conf) {
if (!fs.existsSync(conf)) {
logger.warn(`Invalid config path ${conf}`)
}
nconf.file('customConfigOverride', conf)
}
// environment override
if (environment) {
const envPath = `${appRoot}/config/${environment}.json`
if (!fs.existsSync(envPath)) {
logger.warn(`No config found for env ${environment} at path ${envPath}`)
}
nconf.file('environmentOverride', `${appRoot}/config/${environment}.json`)
}
// load the default config file
nconf.file('default', `${appRoot}/config/default.json`)
// Return the result
}
function loadEnvSpecificConfig(dir) {
const baseDir = path.join(process.cwd(), dir);
const envFile = path.join(baseDir, `${process.env.ACTIVE_PROFILE}.json`);
const defaultFile = path.join(baseDir, 'default.json');
nconf.file(envFile, envFile);
nconf.file(defaultFile, defaultFile);
}
function Config() {
nconf.argv().env("_");
var environment = nconf.get("NODE:ENV") || "development";
nconf.file(environment, {file: path.resolve(__dirname, '../config/' + environment + '.json')});
nconf.file('default', {file: path.resolve(__dirname, '../config/default.json')});
}
function loadConfig(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');
}
var isPrimary = nconf.get('isPrimary');
file: path.resolve(config_dir, 'shared.js')
}).add('shared_json', {
type: 'file',
readOnly: true,
file: path.resolve(config_dir, 'shared.json')
}).add('home_js', {
type: 'file',
readOnly: true,
file: path.resolve(user_home, `.telegrammer.js`)
}).add('home_json', {
type: 'file',
readOnly: true,
file: path.resolve(user_home, `.telegrammer.json`)
});
} else if (statSync.isFile()) {
Config.file({
file: config_dir
});
}
Config.env('__');
for (let key in Config.stores) {
let store = Config.stores[key];
if (store.type === 'file') {
store.loadSync();
}
}
Config.load_from = init;
initialized = true;
return Config;
}