spserver/lib/config.js

55 lines
1 KiB
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',
production: {
port: 80,
bunyan: {
name: nconf.get('name') || 'spserver',
streams: [{
stream: 'process.stdout',
level: 'info'
}
]
},
},
development: {
port: 3001,
bunyan: {
name: nconf.get('name') || 'spserver',
streams: [{
stream: 'process.stdout',
level: 'debug'
}
]
},
}
});
module.exports = nconf;