Files
WRNexusJS/examples/basic-app/app/env.ts
T
2026-07-12 15:55:18 +05:30

15 lines
606 B
TypeScript

// Validated environment configuration. `parseEnv` reads Bun.env / process.env,
// coerces values by the schema, and throws ONE readable error at startup if
// anything is missing or the wrong type — so misconfiguration fails fast.
//
// These are all optional so the example runs with zero setup; in a real app you
// would make secrets/URLs required, e.g. `DATABASE_URL: v.string().min(1)`.
import { v, parseEnv } from "@wrnexus/validation";
export const env = parseEnv<{ NODE_ENV?: string; PORT?: number }>(
v.object({
NODE_ENV: v.string().optional(),
PORT: v.number().optional(),
}),
);