Files
blitzkit/src/core/blitzkrieg/secrets.ts
T
2023-10-14 11:36:48 -05:00

26 lines
539 B
TypeScript

import { config } from 'dotenv';
config();
export const SECRET_KEYS = [
'DISCORD_TOKEN',
'GH_TOKEN',
'DISCORD_BLITZ_DB',
] as const;
export type SECRET = typeof SECRET_KEYS extends readonly (infer T)[]
? T
: never;
export const secrets = SECRET_KEYS.reduce<Partial<Record<SECRET, string>>>(
(accumulator, key) => ({
...accumulator,
get [key](): string {
if (!(key in process.env)) throw new Error(`Secret ${key} not provided`);
return process.env[key]!;
},
}),
{},
) as Record<SECRET, string>;