* Initializes and parses given environment variables using zod * @returns Initialized env vars
()
| 16 | * @returns Initialized env vars |
| 17 | */ |
| 18 | function initEnv() { |
| 19 | // biome-ignore lint/nursery/noProcessEnv: This should be the only place to use process.env directly |
| 20 | const envData = envSchema.safeParse(process.env) |
| 21 | |
| 22 | if (!envData.success) { |
| 23 | // biome-ignore lint/suspicious/noConsole: We want this to be logged |
| 24 | console.error("❌ Invalid environment variables:", envData.error.flatten().fieldErrors) |
| 25 | throw new Error("Invalid environment variables") |
| 26 | } |
| 27 | |
| 28 | env = envData.data |
| 29 | Object.freeze(env) |
| 30 | |
| 31 | // Do not log the message when running tests |
| 32 | if (env.NODE_ENV !== "test") { |
| 33 | // biome-ignore lint/suspicious/noConsole: We want this to be logged |
| 34 | console.log("✅ Environment variables loaded successfully") |
| 35 | } |
| 36 | return env |
| 37 | } |
| 38 | |
| 39 | export function getServerEnv() { |
| 40 | if (env) return env |
no outgoing calls
no test coverage detected
searching dependent graphs…