-
Notifications
You must be signed in to change notification settings - Fork 50
/
config.js
56 lines (46 loc) · 1.24 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
import { URL } from 'url';
if (process.env.NODE_ENV !== 'production') {
const dotenv = await import('dotenv');
dotenv.config();
}
const config = process.env;
const deps = [
'ZM_CLIENT_ID',
'ZM_CLIENT_SECRET',
'ZM_REDIRECT_URL',
'SESSION_SECRET',
];
// Check that we have all our config dependencies
let hasMissing = !config;
for (const dep in deps) {
const conf = deps[dep];
const str = config[conf];
if (!str || typeof str !== 'string') {
console.error(`${conf} is required`);
hasMissing = true;
}
}
if (hasMissing) throw new Error('Missing required .env values...exiting');
try {
new URL(config.ZM_REDIRECT_URL);
} catch (e) {
throw new Error(`Invalid ZM_REDIRECT_URL: ${e.message}`);
}
export const zoomApp = {
host: config.ZM_HOST || 'https://zoom.us',
clientId: config.ZM_CLIENT_ID,
clientSecret: config.ZM_CLIENT_SECRET,
redirectUrl: config.ZM_REDIRECT_URL,
sessionSecret: config.SESSION_SECRET,
};
// Zoom App Info
export const appName = config.APP_NAME || 'zoom-app';
export const redirectUri = zoomApp.redirectUrl;
// HTTP
export const port = config.PORT || '3000';
// require secrets are explicitly imported
export default {
appName,
redirectUri,
port,
};