mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 19:19:52 +02:00
feat: added more mature secrets handling
This commit is contained in:
1 parent
c72bfa9f71
commit
eca7cbbbeb
26 files changed
+81
-75
No files matched your search
@@ -0,0 +1,15 @@
|
||||
const SECRET_KEYS = ['DISCORD_TOKEN', 'WARGAMING_APPLICATION_ID'] as const;
|
||||
|
||||
type SECRET_KEY = typeof SECRET_KEYS extends readonly (infer T)[] ? T : never;
|
||||
|
||||
export const secrets = SECRET_KEYS.reduce<Partial<Record<SECRET_KEY, string>>>(
|
||||
(accumulator, key) => ({
|
||||
...accumulator,
|
||||
|
||||
get [key](): string {
|
||||
if (!(key in process.env)) throw new Error(`Key ${key} not provided`);
|
||||
return process.env[key]!;
|
||||
},
|
||||
}),
|
||||
{},
|
||||
) as Record<SECRET_KEY, string>;
|
||||
Reference in new issue
Block a user