-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
42 lines (36 loc) · 1.18 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
/* eslint-env node */
const fs = require('fs');
let dependencies = {};
try {
dependencies = JSON.parse(fs.readFileSync('dependencies/dependencies.json', 'utf8'));
} catch (e) {
console.error('Error reading dependencies/dependencies.json! The server will be crippled.');
console.error('Please run python3 dependencies/build.py to generate.');
console.error(e);
}
module.exports = {
get: () => {
return {
server: {
port: getEnvVarOrDefault('SERVER_PORT', 3000),
feedbackWebhookURL: getEnvVarOrDefault('FEEDBACK_WEBHOOK_URL', ''),
dependencies
},
caching: {
staticMaxAge: getEnvVarOrDefault('CACHING_STATIC_MAX_AGE', 60 * 60 * 1000),
},
dbUrl: getEnvVarOrDefault('API_URL', 'https://db-prerelease.botballacademy.org'),
};
},
};
function getEnvVarOrDefault(variableName, defaultValue) {
return process.env[variableName] !== undefined
? process.env[variableName]
: defaultValue;
}
// function getEnvVarOrThrow(variableName) {
// if (process.env[variableName] === undefined) {
// throw new Error(`Required environment variable is not set: ${variableName}`);
// }
// return process.env[variableName];
// }