-
Notifications
You must be signed in to change notification settings - Fork 158
/
config.js
41 lines (36 loc) · 868 Bytes
/
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
'use strict'
const joi = require('joi')
const envVarsSchema = joi.object({
NODE_ENV: joi.string()
.allow(['development', 'production', 'test'])
.default('production'),
PROCESS_TYPE: joi.string()
.allow(['web', 'worker'])
.required(),
LOGGER_LEVEL: joi.string()
.allow(['test', 'error', 'warn', 'info', 'verbose', 'debug', 'silly'])
.when('NODE_ENV', {
is: 'development',
then: joi.default('silly')
})
.when('NODE_ENV', {
is: 'production',
then: joi.default('info')
})
.when('NODE_ENV', {
is: 'test',
then: joi.default('warn')
})
})
.unknown().required()
const envVars = joi.attempt(process.env, envVarsSchema)
const config = {
env: envVars.NODE_ENV,
process: {
type: envVars.PROCESS_TYPE
},
logger: {
level: envVars.LOGGER_LEVEL
}
}
module.exports = config