diff options
Diffstat (limited to 'packages/integrations/cloudflare/src/utils/env.ts')
-rw-r--r-- | packages/integrations/cloudflare/src/utils/env.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/integrations/cloudflare/src/utils/env.ts b/packages/integrations/cloudflare/src/utils/env.ts new file mode 100644 index 000000000..e450038eb --- /dev/null +++ b/packages/integrations/cloudflare/src/utils/env.ts @@ -0,0 +1,15 @@ +import type { GetEnv } from 'astro/env/setup'; + +export const createGetEnv = + (env: Record<string, unknown>): GetEnv => + (key) => { + const v = env[key]; + if (typeof v === 'undefined' || typeof v === 'string') { + return v; + } + if (typeof v === 'boolean' || typeof v === 'number') { + // let astro:env handle the validation and transformation + return v.toString(); + } + return undefined; + }; |