-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
73 lines (69 loc) · 1.8 KB
/
config.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
var convict = require('convict');
convict.addFormat(require('convict-format-with-validator').ipaddress);
// Define a schema
var config = convict({
env: {
doc: 'The application environment.',
format: ['production', 'development', 'test'],
default: 'development',
env: 'NODE_ENV',
arg: 'env'
},
server: {
port: {
doc: 'The port to bind.',
format: 'port',
default: 9000,
env: 'PORT',
arg: 'port'
},
ip: {
doc: 'The IP address to bind.',
format: 'ipaddress',
default: '127.0.0.1',
env: 'IP_ADDRESS',
},
enableHttpLogging: {
doc: 'Enable http request logging',
format: Boolean,
default: true,
env: 'HTTP_LOGGING'
},
enableCompression: {
doc: 'Enable Compression',
format: Boolean,
default: true,
env: 'COMPRESSION'
}
},
db: {
host: {
doc: 'Database host name/IP',
format: '*',
default: 'server1.dev.test'
},
name: {
doc: 'Database name',
format: String,
default: 'users'
}
},
admins: {
doc: 'Users with write access, or null to grant full access without login.',
format: Array,
nullable: true,
default: null
},
secret: {
doc: 'Secret used for session cookies and CSRF tokens',
format: '*',
default: '',
sensitive: true
}
});
// Load environment dependent configuration
var env = config.get('env');
config.loadFile('config/' + env + '.json');
// Perform validation
config.validate({ allowed: 'strict' });
module.exports = config;