-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathappConfig.js
More file actions
40 lines (26 loc) · 743 Bytes
/
appConfig.js
File metadata and controls
40 lines (26 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Created by Dmitry.Mogilko on 12/16/2014.
*/
"use strict";
/**
Save as config/index.js
Config files =
- config/config.json
- config/config.$NODE_ENV.json
- config/config.$NODE_ENV.$USER.json
**/
var path = require('path');
var fs = require('fs');
var os = require('os');
var conf = module.exports = require('nconf')
.argv()
.env()
.defaults({NODE_ENV: 'production'});
//
var files = [
path.join(__dirname, 'config.json'),
path.join(__dirname, 'config.' + conf.get('NODE_ENV') + '.json'),
path.join(__dirname, 'config.' + conf.get('NODE_ENV') + '.' + conf.get('USER') + '.json')
].filter(fs.existsSync);
console.log('Loading config from files', files);
conf.use('memory', {loadFrom: files});