| 1 | // Alchemy modifications are licensed under Apache-2.0. |
| 2 | // This file includes third-party code; see /THIRD_PARTY_LICENSES.md. |
| 3 | // Vendored from `@astrojs/cloudflare` v14.1.3 (`src/utils/env.ts`). |
| 4 | import type { GetEnv } from "astro/env/setup"; |
| 5 | |
| 6 | export const createGetEnv = |
| 7 | (env: Record<string, unknown>): GetEnv => |
| 8 | (key) => { |
| 9 | const v = env[key]; |
| 10 | if (typeof v === "undefined" || typeof v === "string") { |
| 11 | return v; |
| 12 | } |
| 13 | if (typeof v === "boolean" || typeof v === "number") { |
| 14 | // let astro:env handle the validation and transformation |
| 15 | return v.toString(); |
| 16 | } |
| 17 | return undefined; |
| 18 | }; |