INNER CODE UNIT · TypeScript
ProviderConfigurationError
Jazee6/cloudflare-ai-web · app/api/index.ts:5
export class ProviderConfigurationError extends Error {
constructor(name: string) {
super(`Missing required environment variable: ${name}`);
this.name = "ProviderConfigurationError";
}
}
const requireEnvironmentVariable = (name: string): string => {
const value = process.env[name];
if (!value) {
throw new ProviderConfigurationError(name);
}
return value;
};
export const getCloudflareCredentials = () => ({
accountId: requireEnvironmentVariable("CF_ACCOUNT_ID"),
apiKey: requireEnvironmentVariable("CF_WORKERS_AI_TOKEN"),