-
Notifications
You must be signed in to change notification settings - Fork 9
/
config.js
41 lines (36 loc) · 874 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
const dotenv = require('dotenv');
dotenv.config({ silent: true });
const {
PORT = 3000,
SLACK_BASE_URL = 'https://slack.com/api',
DATABASE_URL,
SLACK_VERIFICATION_TOKEN,
SLACK_ACCESS_TOKEN,
NODE_ENV,
SLACK_APP_DISPLAY_NAME = 'Yellow Poll',
SLACK_MESSAGE_BAR_COLOR = '#ffd100',
SLACK_MESSAGE_ICON_EMOJIS = 'bar_chart',
} = process.env;
const defaults = {
SLACK_VERIFICATION_TOKEN: null,
SLACK_ACCESS_TOKEN: null,
};
// Alert to fill the necessary environment variables
Object.keys(defaults).forEach((key) => {
if (!process.env[key]) {
throw new Error(
`Please enter a custom ${key} in .env on the root directory`
);
}
});
module.exports = {
PORT,
SLACK_BASE_URL,
DATABASE_URL,
SLACK_VERIFICATION_TOKEN,
SLACK_ACCESS_TOKEN,
NODE_ENV,
SLACK_APP_DISPLAY_NAME,
SLACK_MESSAGE_BAR_COLOR,
SLACK_MESSAGE_ICON_EMOJIS,
};