(envVarName: string)
| 1 | export function getApiKeyFromEnv(envVarName: string): string { |
| 2 | const env = |
| 3 | typeof globalThis !== 'undefined' && (globalThis as any).window?.env |
| 4 | ? (globalThis as any).window.env |
| 5 | : typeof process !== 'undefined' |
| 6 | ? process.env |
| 7 | : undefined |
| 8 | |
| 9 | const apiKey = env?.[envVarName] |
| 10 | |
| 11 | if (!apiKey) { |
| 12 | throw new Error( |
| 13 | `${envVarName} is not set. Please set the ${envVarName} environment variable or pass the API key directly.`, |
| 14 | ) |
| 15 | } |
| 16 | |
| 17 | return apiKey |
| 18 | } |
no outgoing calls
no test coverage detected