MCPcopy Create free account
hub / github.com/code-forge-io/react-router-devtools / initEnv

Function initEnv

docs/app/env.server.ts:18–37  ·  view source on GitHub ↗

* Initializes and parses given environment variables using zod * @returns Initialized env vars

()

Source from the content-addressed store, hash-verified

16 * @returns Initialized env vars
17 */
18function 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
39export function getServerEnv() {
40 if (env) return env

Callers 1

getServerEnvFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…