fp/services/bot/src/config.ts

45 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-08-27 07:11:24 +00:00
import 'dotenv/config'
2024-08-07 23:43:17 +00:00
2024-08-27 07:11:24 +00:00
const requiredEnvVars = [
'HTTP_PROXY',
'WORKER_CONNECTION_STRING',
'POSTGREST_URL',
'DISCORD_TOKEN',
'DISCORD_CHANNEL_ID',
'DISCORD_GUILD_ID',
'DISCORD_APPLICATION_ID',
'AUTOMATION_USER_JWT',
] as const;
2024-08-07 01:13:58 +00:00
2024-08-27 07:11:24 +00:00
const getEnvVar = (key: typeof requiredEnvVars[number]): string => {
const value = process.env[key];
if (!value) {
throw new Error(`Missing ${key} env var`);
}
return value;
};
2024-08-07 01:13:58 +00:00
export interface Config {
postgrestUrl: string;
2024-08-27 07:11:24 +00:00
httpProxy: string;
token: string;
2024-08-07 01:13:58 +00:00
automationUserJwt: string;
2024-08-07 23:43:17 +00:00
discordGuildId: string;
discordChannelId: string;
connectionString: string;
2024-08-17 02:42:44 +00:00
discordApplicationId: string;
2024-08-07 01:13:58 +00:00
}
2024-08-07 23:43:17 +00:00
export const configs: Config = {
2024-08-27 07:11:24 +00:00
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'),
}