48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import 'dotenv/config'
|
|
|
|
const requiredEnvVars = [
|
|
'HTTP_PROXY',
|
|
'WORKER_CONNECTION_STRING',
|
|
'POSTGREST_URL',
|
|
'DISCORD_TOKEN',
|
|
'DISCORD_CHANNEL_ID',
|
|
'DISCORD_GUILD_ID',
|
|
'DISCORD_APPLICATION_ID',
|
|
'AUTOMATION_USER_JWT',
|
|
'SCOUT_URL'
|
|
] as const;
|
|
|
|
const getEnvVar = (key: typeof requiredEnvVars[number]): string => {
|
|
const value = process.env[key];
|
|
if (!value) {
|
|
throw new Error(`Missing ${key} env var`);
|
|
}
|
|
return value;
|
|
};
|
|
|
|
export interface Config {
|
|
postgrestUrl: string;
|
|
httpProxy: string;
|
|
token: string;
|
|
automationUserJwt: string;
|
|
discordGuildId: string;
|
|
discordChannelId: string;
|
|
connectionString: string;
|
|
discordApplicationId: string;
|
|
scoutUrl: string;
|
|
}
|
|
|
|
|
|
export const configs: Config = {
|
|
scoutUrl: getEnvVar('SCOUT_URL'),
|
|
connectionString: getEnvVar('WORKER_CONNECTION_STRING'),
|
|
httpProxy: getEnvVar('HTTP_PROXY'),
|
|
postgrestUrl: getEnvVar('POSTGREST_URL'),
|
|
token: getEnvVar('DISCORD_TOKEN'),
|
|
automationUserJwt: getEnvVar('AUTOMATION_USER_JWT'),
|
|
discordGuildId: getEnvVar('DISCORD_GUILD_ID'),
|
|
discordChannelId: getEnvVar('DISCORD_CHANNEL_ID'),
|
|
discordApplicationId: getEnvVar('DISCORD_APPLICATION_ID'),
|
|
}
|
|
|