-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
96 lines (80 loc) · 2.78 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
const config = {
HOST: process.env.CORLIEF_HOST || 'localhost',
PORT: process.env.CORLIEF_PORT || 8888,
CORLIEF_PATH: process.env.CORLIEF_PATH || 'localhost:8888',
MONGO: {
DB: process.env.CORLIEF_MONGO_DB || 'corlief',
TEST: process.env.CORLIEF_MONGO_DB_TEST || 'corlief_test',
HOST: process.env.CORLIEF_MONGO_HOST || 'localhost:27017'
},
LOGENTRIES_TOKEN: process.env.CORLIEF_LOGENTRIES_TOKEN,
STORAGE: {
NAME: process.env.CORLIEF_STORAGE_NAME,
KEY: process.env.CORLIEF_STORAGE_KEY,
SECRET: process.env.CORLIEF_STORAGE_SECRET,
REGION: process.env.CORLIEF_STORAGE_REGION,
DOMAIN: process.env.CORLIEF_STORAGE_DOMAIN,
PATH: process.env.NODE_ENV === 'production' ? '/corlief/production/' : '/corlief/dev/',
TEST: '/corlief/test/'
},
DECK: {
HOST: process.env.CORLIEF_DECK_HOST || process.env.NODE_ENV === 'production' ? 'https://deck.sinfo.org' : 'https://deck2.sinfo.org',
PORT: 443,
USER: process.env.DECK_USER,
TOKEN: process.env.DECK_TOKEN
},
COORDINATION_EMAIL: '[email protected]',
MAILGUN: {
API_KEY: process.env.CORLIEF_MAILGUN_API_KEY,
DOMAIN: 'sinfo.org',
HOST: 'api.mailgun.net'
},
CORS: process.env.NODE_ENV === 'production'
? ['*sinfo.org']
: ['*'],
SUBMISSIONS: {
CONTRACTS: process.env.CORLIEF_SUBMISSIONS_CONTRACTS || false,
INFO: process.env.CORLIEF_SUBMISSIONS_INFO || false
},
AUTH: {
TOKEN_ISSUER: process.env.CORLIEF_TOKEN_ISSUER || 'corlief',
TOKEN_ALGORITHM: process.env.CORLIEF_TOKEN_ALGORITHM || 'RS256',
TOKEN_EXPIRY_DATE: process.env.CORLIEF_TOKEN_EXPIRY_DATE || '1d',
GOOGLE: {
CLIENT_ID: process.env.CORLIEF_GOOGLE_APP_ID || 'YOUR APP ID',
CLIENT_SECRET: process.env.CORLIEF_GOOGLE_CLIENT_SECRET || 'YOUR CLIENT SECRET'
}
}
}
const logger = process.env.CORLIEF_LOGENTRIES_TOKEN &&
config.MAILGUN.API_KEY &&
process.env.NODE_ENV === 'production'
? require('logger').getLogger(
process.env.CORLIEF_LOGENTRIES_TOKEN,
config.MAILGUN.API_KEY,
'Corlief'
)
: require('logger').getLogger()
module.exports = config
module.exports.validate = () => {
if (process.env.NODE_ENV === 'production') {
logger.warn('Running in production mode')
if (config.CORLIEF_PATH === undefined) {
logger.error('Env var of CORLIEF_PATH not defined')
process.exit(1)
}
if (config.LOGENTRIES_TOKEN === undefined) {
logger.warn('Production mode without logentries token given')
}
if (config.MAILGUN.API_KEY === undefined) {
logger.error('Env var of CORLIEF_MAILGUN_API_KEY not defined')
process.exit(1)
}
}
for (let key of Object.keys(config.STORAGE)) {
if (config.STORAGE[key] === undefined) {
logger.error(`Env var of STORAGE.${key} not defined`)
process.exit(1)
}
}
}