-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.js
44 lines (36 loc) · 1.09 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
const fs = require('fs');
const azure = {
identityMetadata: process.env.IDENTITY_METADATA,
clientID: process.env.REACT_APP_CLIENT_ID,
validateIssuer: process.env.NODE_ENV == 'production' ? true : false
};
const github = {
clientID: process.env.REACT_APP_GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
botToken: process.env.GITHUB_BOT_TOKEN,
botLogin: process.env.REACT_APP_GITHUB_BOT_LOGIN,
webHookSecret: process.env.GITHUB_WEBHOOK_SECRET,
};
const app = {
groupConfigPath: process.env.GROUP_CONFIG_PATH,
sendGridApiKey: process.env.SENDGRID_API_KEY,
emailSender: process.env.SENDGRID_EMAIL_SENDER
};
function validateConfig(configObject) {
for (let prop of Object.keys(configObject)) {
if (configObject[prop] === undefined) throw new Error(`Missing environment variable: ${prop}`);
}
}
function loadAppData() {
return JSON.parse(fs.readFileSync(`${__dirname}/${app.groupConfigPath}`, 'utf-8'));
}
validateConfig(azure);
validateConfig(github);
validateConfig(app);
const appData = loadAppData();
module.exports = {
azure,
github,
app,
appData
};