-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
56 lines (52 loc) · 1.24 KB
/
index.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
const Convict = require('convict');
// Define a schema
const Config = Convict({
env: {
doc: 'The application environment.',
format: ['production', 'development', 'test'],
default: 'development',
env: 'NODE_ENV',
arg: 'env'
},
ip: {
doc: 'The IP address to bind.',
format: 'ipaddress',
default: '127.0.0.1',
env: 'IP_ADDRESS',
arg: 'ipaddr'
},
domain: {
doc: 'The domain hosting the app',
format: '*',
default: 'localhost',
env: 'DOMAIN',
arg: 'domain'
},
port: {
doc: 'The port to bind.',
format: 'port',
default: 3000,
env: 'PORT',
arg: 'port'
},
forceHttps: {
doc: 'Is HTTPS required?',
format: Boolean,
default: true,
env: 'FORCE_HTTPS',
arg: 'https'
},
newestVersion: {
doc: 'Newest API Version',
format: ['v1'],
default: 'v1',
env: 'NEWEST_VERSION',
arg: 'version'
}
});
// Load environment dependent configuration
const env = Config.get('env');
Config.loadFile(`${__dirname}/${env}.json`);
// Perform validation
Config.validate({allowed: 'strict'});
module.exports = Config;