| Name | Last commit date | |
|---|---|---|
| .. | ||
| src | 7 months ago | |
| CHANGELOG.md | 7 months ago | |
| package.json | 7 months ago | |
| README.md | 7 months ago | |
| tsconfig.json | 7 months ago | |
| vitest.config.ts | 7 months ago | |
@executor/env
Vendored environment tooling based on rayhanadev/effect-env, with runtime ergonomics inspired by t3-oss/t3-env.
What this adds
Envhelper constructors for EffectConfigvaluesmakeEnvfor Effect Context/Layer integrationcreateEnv(shape, options)for runtime env assembly with:- an optional
prefixfor client-safe keys runtimeEnvonValidationError/onInvalidAccessskipValidationemptyStringAsUndefinedextendscreateFinalConfigcustomization hook
- an optional
Example
import { createEnv, Env } from "@executor/env";
export const shared = createEnv(
{
NODE_ENV: Env.literal("NODE_ENV", "development", "test", "production"),
},
{
runtimeEnv: process.env,
},
);
export const web = createEnv(
{
PUBLIC_API_URL: Env.url("PUBLIC_API_URL"),
},
{
prefix: "PUBLIC_",
runtimeEnv: import.meta.env,
},
);
export const server = createEnv(
{
DATABASE_URL: Env.url("DATABASE_URL"),
PORT: Env.numberOr("PORT", 3000),
},
{
runtimeEnv: process.env,
extends: [shared],
},
);