Readme

Utility to retrieve typesafe environment variable configuration with Zod.

const { DB_HOST } = config({ DB_HOST: z.string(), }); // DB_HOST is a string, or an error is thrown.
1
2
3
4
5
6
import process from "node:process";
import { z } from "npm:zod";
export function config<T extends z.ZodRawShape>(schema: T) {
return z.object(schema).parse(process.env);
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
June 14, 2024