INNER CODE UNIT · TypeScript
requireEnvironmentVariable
Jazee6/cloudflare-ai-web · app/api/index.ts:12
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"),
});
export const getCloudflareGatewayCredentials = () => {
const gatewayId = process.env.CF_AI_GATEWAY_NAME;
if (!gatewayId) {
return undefined;
}