-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
124 lines (119 loc) · 2.65 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const convict = require('convict');
const fs = require('fs');
const convictFormatWithValidator = require('convict-format-with-validator');
convict.addFormats(convictFormatWithValidator);
const config = convict({
env: {
doc: 'The application environment.',
format: ['production', 'development', 'test'],
default: 'development',
env: 'NODE_ENV',
},
ip: {
doc: 'The IP address to bind.',
format: 'ipaddress',
default: '127.0.0.1',
env: 'IP_ADDRESS',
},
accessTokenExpiration: {
doc: 'The access token default expiration time in seconds',
format: 'integer',
default: 900, // 15 minutes
env: 'ACCESS_TOKEN_EXPIRATION',
},
refreshTokenExpiration: {
doc: 'The refresh token default expiration time in seconds',
format: 'integer',
default: 1209600, // 2 weeks
env: 'REFRESH_TOKEN_EXPIRATION',
},
host: {
doc: 'The server host name',
format: String,
default: 'localhost:3000',
env: 'HOST',
},
port: {
doc: 'The port to bind.',
format: 'port',
default: 3000,
env: 'PORT',
arg: 'port',
},
database: {
host: {
doc: 'Database host name/IP',
format: '*',
default: 'localhost',
env: 'DATABASE_HOST',
},
client: {
doc: 'Database client',
format: '*',
default: 'mysql2',
env: 'DATABASE_CLIENT',
},
port: {
doc: 'The port the db server',
format: 'port',
default: 3306,
env: 'DATABASE_PORT',
},
name: {
doc: 'Database name',
format: String,
default: 'ronda',
env: 'DATABASE_NAME',
},
username: {
doc: 'Database user',
format: String,
default: 'dev',
env: 'DATABASE_USER',
},
password: {
doc: 'Database password',
format: String,
default: 'dev',
env: 'DATABASE_PASSWORD',
},
},
email: {
defaultFrom: {
doc: 'Default Email from address',
format: 'email',
default: '[email protected]',
env: 'EMAIL_FROM',
},
host: {
doc: 'SMTP host',
format: '*',
default: 'localhost',
env: 'EMAIL_HOST',
},
port: {
doc: 'SMTP port',
format: 'port',
default: 2525,
env: 'EMAIL_PORT',
},
user: {
doc: 'SMTP user',
format: String,
default: 'root',
env: 'EMAIL_USER',
},
pass: {
doc: 'SMTP pass',
format: String,
default: 'root',
env: 'EMAIL_PASS',
},
},
});
const configFilePath = `./config/${config.get('env')}.json`;
if (fs.existsSync(configFilePath)) {
config.loadFile(configFilePath);
}
config.validate({ allowed: 'strict' });
module.exports = config;