Skip to content

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.

T extends EnvObject = EnvObject

EnvParserOptions

EnvParser<T>

src/config.ts
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
}));