-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.ts
More file actions
62 lines (56 loc) · 2.47 KB
/
config.ts
File metadata and controls
62 lines (56 loc) · 2.47 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
// FILL IN THIS INFORMATION IN .ENV
export const runningInDevMode: boolean = process.argv.includes("--dev");
// Staging mode is for only testing the production database before breaking the actual production bot
// Run `bun db:migrate:staging` to migrate the staging database and check for any mistakes before running `bun db:migrate:prod`
// Do NOT use this mode for regular testing, use --dev for that
export const runningInStagingMode: boolean = process.argv.includes("--staging");
if (runningInDevMode && runningInStagingMode) {
throw new Error("Cannot run in both dev and staging mode!");
}
export interface Config {
youtubeInnertubeProxyUrl: string | null;
updateIntervalYouTube: number;
updateIntervalTwitch: number;
databaseUrl: string | undefined;
discordWaitForGuildCacheTime: number;
discordCollectorTimeout: number;
discordComponentsPageSize: number;
}
export const config: Config = {
youtubeInnertubeProxyUrl: process.env?.YOUTUBE_INNERTUBE_PROXY_URL ?? null,
updateIntervalYouTube: process.env?.CONFIG_UPDATE_INTERVAL_YOUTUBE
? parseInt(process.env?.CONFIG_UPDATE_INTERVAL_YOUTUBE) * 1000
: 60_000,
updateIntervalTwitch: process.env?.CONFIG_UPDATE_INTERVAL_TWITCH
? parseInt(process.env?.CONFIG_UPDATE_INTERVAL_TWITCH) * 1000
: 60_000,
databaseUrl: runningInDevMode
? process.env?.POSTGRES_DEV_URL
: runningInStagingMode
? process.env?.POSTGRES_STAGING_URL
: process.env?.POSTGRES_URL,
discordWaitForGuildCacheTime: process.env
?.CONFIG_DISCORD_WAIT_FOR_GUILD_CACHE_TIME
? parseInt(process.env?.CONFIG_DISCORD_WAIT_FOR_GUILD_CACHE_TIME) * 1000
: 10_000,
discordCollectorTimeout: process.env?.CONFIG_DISCORD_COLLECTOR_TIMEOUT
? parseInt(process.env?.CONFIG_DISCORD_COLLECTOR_TIMEOUT) * 1000
: 60_000,
discordComponentsPageSize: process.env?.CONFIG_DISCORD_COMPONENTS_PAGE_SIZE
? parseInt(process.env?.CONFIG_DISCORD_COMPONENTS_PAGE_SIZE)
: 10,
};
interface Env {
discordToken: string | undefined;
youtubeApiKey: string | undefined;
twitchClientId: string | undefined;
twitchClientSecret: string | undefined;
}
export const env: Env = {
discordToken: runningInDevMode
? process.env?.DISCORD_DEV_TOKEN
: process.env?.DISCORD_TOKEN,
youtubeApiKey: process.env?.YOUTUBE_API_KEY,
twitchClientId: process.env?.TWITCH_CLIENT_ID,
twitchClientSecret: process.env?.TWITCH_CLIENT_SECRET,
};