Node.js implementation of the Env abstraction, backed by process.env by default. Accepts an optional variables record to override the source. Provides typed access to environment variables with getString, getNumber, and getBoolean families.
See Env README for the full interface and usage.
import { Container } from "@webiny/di";
import { Env } from "@webiny/stdlib";
import { ProcessEnvFeature } from "@webiny/stdlib/node";
const container = new Container();
ProcessEnvFeature.register(container);
const env = container.resolve(Env);
const port = env.getNumber("PORT", 3000);ProcessEnvFeature.register(container, {
variables: { ...process.env, MY_VAR: "overridden" }
});import { createProcessEnv } from "@webiny/stdlib/node";
// Defaults to process.env
const env = createProcessEnv();
// With custom variables
const env = createProcessEnv({
variables: { ...process.env, MY_VAR: "overridden" }
});