Spaces:
Sleeping

File size: 1,181 Bytes
1305386
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
/**
 * ๐Ÿ” API KEYS CONFIGURATION
 * 
 * Centralized API keys management from environment variables.
 * All API keys should be stored in .env file and loaded via this module.
 * 
 * NEVER hard-code API keys in source code!
 */
 
/**
 * Validate that all required API keys are present
 * Should be called at application startup
 */
export function validateAPIKeys(): { valid: boolean; missing: string[] } {
    const missing: string[] = []; 

    return {
        valid: missing.length === 0,
        missing
    };
}

/**
 * Throw error if API keys are missing (strict mode)
 * Use this in production to fail-fast
 */
export function requireAPIKeys(): void {
    const validation = validateAPIKeys();
    
    if (!validation.valid) {
        console.error('โŒ MISSING REQUIRED API KEYS:');
        validation.missing.forEach(key => {
            console.error(`   - ${key}`);
        });
        console.error('\n๐Ÿ’ก Add these keys to your .env file');
        console.error('   See .env.example for reference\n');
        throw new Error(`Missing required API keys: ${validation.missing.join(', ')}`);
    }
    
    console.log('โœ… All required API keys are configured');
}