-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathconfig.ts
More file actions
119 lines (118 loc) · 3.99 KB
/
config.ts
File metadata and controls
119 lines (118 loc) · 3.99 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
* This function tries to fetch an environment variable with the given name.
* If it doesn't exist, it exits the application.
*
* @author Soni
*
* @param name The name of the environment variable to fetch
* @returns The value of the environment variable if it exists
*/
function requireEnv (name: string): string {
// Stop process if the environment variable isn't present
if (!process.env[name]) {
console.error(`Required environment variable ${name} not present, exiting...`);
process.exit(1);
}
return process.env[name];
}
/**
* This object holds the global configuration of Epochtal that all parts of the application read from.
* When Epochtal is started, this configuration is populated with data inherited from environment variables.
* If parts of the configuration are not available as environment variables,
* it will be populated with predefined default values where possible.
*
* @author Soni
*/
export const CONFIG: object = {
/**
* External API keys used by Epochtal
*/
API_KEY: {
/**
* Steam API key
*/
STEAM: requireEnv("STEAM_API_KEY"),
/**
* Discord API key
*/
DISCORD: requireEnv("DISCORD_API_KEY")
},
/**
* Internal secrets
*/
SECRET: {
/**
* JWT (cookie) data encoding secret
*/
JWT: requireEnv("JWT_SECRET"),
/**
* Internal request authentication secret
*/
INTERNAL: requireEnv("INTERNAL_SECRET")
},
/**
* The filesystem directories in which non-volatile data is stored
*/
DIR: {
/**
* The directory to store runtime data in.
* This includes user data, run data, category data, etc.
*/
DATA: process.env.DATA_DIR ?? `${__dirname}/data`,
/**
* The directory to store binary dependencies in.
* Epochtal will look for its dependencies in this directory.
*/
BIN: process.env.BIN_DIR ?? `${__dirname}/bin`,
/**
* The directory to store runtime secrets in.
* This includes curation weights and TLS keys.
*/
SECRETS: process.env.SECRETS_DIR ?? `${__dirname}/secrets`
},
/**
* The web URL of this deployed instance, including hostname and port, excluding protocol.
* This is used to populate redirect URLs.
*
* NOTE: If running in a containerized manner,
* make sure the port specified here is the publicly exposed port for the service.
*/
WEB_URL: process.env.WEB_URL ?? "localhost:8080",
/**
* The port to run the Epochtal webserver on.
*/
PORT: process.env.PORT ?? 8080,
/**
* Whether to host the webserver with TLS enabled.
* If enabled, certificates need to be provided as `fullchain.pem` and `privkey.pem` in the SECRETS_DIR directory.
*/
USE_TLS: process.env.USE_TLS === "true",
/**
* Whether clients are expected to connect to the exposed website with "https://"
* (whether redirect URLs should be written with HTTPS instead of HTTP).
* This will likely be the same as USE_TLS unless this deployment is exposed through a reverse proxy that terminates TLS.
*/
USE_HTTPS: process.env.USE_HTTPS === "true",
/**
* The Discord channels used for this deployment
*/
DISCORD_CHANNEL: {
/**
* The channel ID of the Discord announcement channel
*/
ANNOUNCEMENTS: requireEnv("DISCORD_CHANNEL_ANNOUNCE"),
/**
* The channel ID of the Discord report channel
*/
REPORTS: requireEnv("DISCORD_CHANNEL_REPORT"),
/**
* The channel ID of the Discord update channel
*/
UPDATES: requireEnv("DISCORD_CHANNEL_UPDATE")
},
/**
* The time span for the curation algorithm to curate for, in seconds.
* This defines how far back in time the curation algorithm fetches maps from.
*/
CURATE_SECONDS: process.env.CURATE_SECONDS ?? 604800 // Defaults to one week
};