Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions packages/core/env/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @executor/env

## 1.4.0

- Add vendored Effect env package with t3-env style runtime validation ergonomics.
52 changes: 52 additions & 0 deletions packages/core/env/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# @executor/env

Vendored environment tooling based on [`rayhanadev/effect-env`](https://github.com/rayhanadev/effect-env), with runtime ergonomics inspired by [`t3-oss/t3-env`](https://github.com/t3-oss/t3-env).

## What this adds

- `Env` helper constructors for Effect `Config` values
- `makeEnv` for Effect Context/Layer integration
- `createEnv(shape, options)` for runtime env assembly with:
- an optional `prefix` for client-safe keys
- `runtimeEnv`
- `onValidationError` / `onInvalidAccess`
- `skipValidation`
- `emptyStringAsUndefined`
- `extends`
- `createFinalConfig` customization hook

## Example

```ts
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],
},
);
```
21 changes: 21 additions & 0 deletions packages/core/env/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@executor/env",
"private": true,
"type": "module",
"version": "1.4.0",
"exports": {
".": "./src/index.ts"
},
"scripts": {
"typecheck": "bunx tsc --noEmit -p tsconfig.json",
"test": "vitest run"
},
"dependencies": {
"effect": "catalog:"
},
"devDependencies": {
"@effect/vitest": "catalog:",
"typescript": "catalog:",
"vitest": "catalog:"
}
}
Loading