createEnvParser
createEnvParser<
T>(options):EnvParser<T>
Defined in: create-env-parser.ts:29
Create an env parser for your app.
Call this once in your app’s config.ts. Use get() to look up values and map() to define your app’s config shape in one place. Nothing outside config.ts should ever touch process.env directly.
Type Parameters
Section titled “Type Parameters”T extends EnvObject = EnvObject
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”EnvParser<T>
Example
Section titled “Example”import { createEnvParser } from "@magnite/env-parser";
const { map, deprecate } = createEnvParser({ appName: "adcp-service" });
deprecate("database_url", "db__primary__url");
export const config = map((get) => ({ port: get("port") ?? 3000, db: { url: get("db.primary.url") ?? get("database_url"), }, auth: get("auth0"), // returns the whole auth0 namespace object}));