-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenv.ts
More file actions
41 lines (36 loc) · 1.18 KB
/
env.ts
File metadata and controls
41 lines (36 loc) · 1.18 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
import './loadEnvFile.js';
function optionalEnv(key: string): string | undefined {
return process.env[key];
}
function requireEnv(key: string): string {
const value = process.env[key];
if (!value) {
console.error(`❌ Required environment variable ${key} is not set`);
console.error('Please check your .env.local file or CI/CD configuration');
process.exit(1);
}
return value;
}
// Single source of truth for all configuration
export const config = {
discord: {
token: requireEnv('DISCORD_TOKEN'),
clientId: requireEnv('CLIENT_ID'),
},
guides: {
channelId: requireEnv('GUIDES_CHANNEL_ID'),
trackerPath: optionalEnv('GUIDES_TRACKER_PATH'),
},
// Add more config sections as needed:
// database: {
// url: requireEnv('DATABASE_URL'),
// },
// api: {
// openaiKey: optionalEnv('OPENAI_API_KEY'),
// },
};
export type Config = typeof config;
// Log loaded configuration (without sensitive values)
console.log('✅ Configuration loaded successfully');
console.log(`📋 Client ID: ${config.discord.clientId ? config.discord.clientId : '❌ missing'}`);
console.log(`🔑 Token: ${config.discord.token ? '***configured***' : '❌ missing'}`);