forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment.js
64 lines (51 loc) · 1.47 KB
/
environment.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
const path = require('path');
const fs = require('fs');
const {
NODE_ENV = 'production',
HTTP_PORT = '8080',
HTTPS_PORT = '8443',
GITHUB_CLIENT_ID,
GITHUB_CLIENT_SECRET,
GITHUB_WEBHOOK_SECRET,
CREDENTIALS_ENABLED = '0',
CREDENTIALS_PATH,
CREDENTIALS_CA,
CREDENTIALS_KEY,
CREDENTIALS_CERT,
} = process.env;
const isEnabled = v => v === '1';
const __PROD__ = NODE_ENV === 'production';
const __DEV__ = !__PROD__;
const httpPort = parseInt(HTTP_PORT);
const httpsPort = parseInt(HTTPS_PORT);
const githubClientId = GITHUB_CLIENT_ID;
const githubClientSecret = GITHUB_CLIENT_SECRET;
const githubWebhookSecret = GITHUB_WEBHOOK_SECRET;
const read = (file) => fs.readFileSync(path.resolve(CREDENTIALS_PATH, file));
const credentials = isEnabled(CREDENTIALS_ENABLED) && {
ca: read(CREDENTIALS_CA),
key: read(CREDENTIALS_KEY),
cert: read(CREDENTIALS_CERT),
};
const buildPath = path.resolve(__dirname, 'build');
const frontendBuildPath = path.resolve(buildPath, 'frontend');
const backendBuildPath = path.resolve(buildPath, 'backend');
const srcPath = path.resolve(__dirname, 'src');
const frontendSrcPath = path.resolve(srcPath, 'frontend');
const backendSrcPath = path.resolve(srcPath, 'backend');
const apiEndpoint = '/api';
module.exports = {
__PROD__,
__DEV__,
httpPort,
httpsPort,
githubClientId,
githubClientSecret,
githubWebhookSecret,
credentials,
frontendBuildPath,
backendBuildPath,
frontendSrcPath,
backendSrcPath,
apiEndpoint,
};