spserver/lib/config.js

50 lines
968 B
JavaScript
Raw Normal View History

2015-02-02 09:52:31 +00:00
'use strict';
var nconf = require('nconf');
2016-12-15 22:43:52 +00:00
// Load arguments as highest priority
2015-02-02 09:52:31 +00:00
nconf.argv(require('./arguments'));
2016-12-15 22:43:52 +00:00
// Overrides
2015-02-02 09:52:31 +00:00
var overrides = {};
if (nconf.get('prod')) {
overrides.NODE_ENV = 'production';
2016-12-15 22:43:52 +00:00
} else if (nconf.get('debug')) {
2015-02-02 09:52:31 +00:00
overrides.NODE_ENV = 'development';
}
2016-12-15 22:43:52 +00:00
// Load overrides as second priority
2015-02-02 09:52:31 +00:00
nconf.overrides(overrides);
2016-12-15 22:43:52 +00:00
// Load enviroment variables as third priority
2015-02-02 09:52:31 +00:00
nconf.env();
2016-12-15 22:43:52 +00:00
// Load the config if it exists.
2015-02-02 09:52:31 +00:00
nconf.file(nconf.get('config') || './config.json');
2016-12-15 22:43:52 +00:00
// Default variables
2015-02-02 09:52:31 +00:00
nconf.defaults({
name: nconf.get('name') || 'spserver',
NODE_ENV: 'development',
2016-12-17 01:18:39 +00:00
ip: '0.0.0.0',
2015-02-02 09:52:31 +00:00
production: {
port: 80,
bunyan: {
name: nconf.get('name') || 'spserver',
stream: 'process.stdout',
level: 'info',
2015-02-02 09:52:31 +00:00
},
},
development: {
port: 3001,
bunyan: {
name: nconf.get('name') || 'spserver',
stream: 'process.stdout',
level: 'debug',
2015-02-02 09:52:31 +00:00
},
},
2015-02-02 09:52:31 +00:00
});
module.exports = nconf;