@thexjs/env 0.1.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +8 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @thexjs/env
2
2
 
3
- Type-safe environment variable validation for [x](https://www.npmjs.com/package/@thexjs/core) framework apps. Define a schema once, get parsed/typed values back, and fail fast with a clear error if something's missing or malformed — instead of finding out at runtime deep in your app.
3
+ Type-safe environment variable validation for [x](https://www.npmjs.com/package/@thexjs/core) framework apps. Define a schema once, get parsed/typed values back, and fail fast with a clear error if something's missing or malformed, instead of finding out at runtime deep in your app.
4
4
 
5
5
  ```sh
6
6
  bun add @thexjs/env
@@ -19,9 +19,9 @@ export const env = createEnv({
19
19
  NODE_ENV: oneOf(["development", "production", "test"]),
20
20
  },
21
21
  client: {
22
- NEXT_PUBLIC_API_URL: url(),
22
+ THEXJS_PUBLIC_API_URL: url(),
23
23
  },
24
- clientPrefix: "NEXT_PUBLIC_",
24
+ clientPrefix: "THEXJS_PUBLIC_",
25
25
  runtimeEnv: process.env,
26
26
  });
27
27
 
@@ -48,7 +48,7 @@ Environment validation failed:
48
48
  | `oneOf([...values])` | one of the given string literals | return type is narrowed to the literal union |
49
49
  | `url()` | any string parseable by `new URL(...)` | |
50
50
 
51
- Each validator is just `{ parse(input: string | undefined): T }` (the `EnvValidator<T>` interface, exported as a type) — write your own for anything not covered above:
51
+ Each validator is just `{ parse(input: string | undefined): T }` (the `EnvValidator<T>` interface, exported as a type). Write your own for anything not covered above:
52
52
 
53
53
  ```ts
54
54
  import type { EnvValidator } from "@thexjs/env";
@@ -65,11 +65,13 @@ function json<T>(): EnvValidator<T> {
65
65
 
66
66
  ## `client` / `clientPrefix`
67
67
 
68
- The `client` schema is for variables you're comfortable exposing to the browser. `clientPrefix` enforces that every client key actually starts with that prefix (e.g. `NEXT_PUBLIC_`, `PUBLIC_`) — a key that doesn't match fails validation, so you can't accidentally leak a server-only variable through the client schema by mistake.
68
+ The `client` schema is for variables you're comfortable exposing to the browser. `clientPrefix` enforces that every client key actually starts with that prefix. A key that doesn't match fails validation, so you can't accidentally leak a server-only variable through the client schema by mistake.
69
+
70
+ When used with `@thexjs/core`, keep the default `THEXJS_PUBLIC_` prefix: the framework's build-time env isolation only lets `THEXJS_PUBLIC_`-prefixed variables reach client bundles, and any other server-only `process.env` / `Bun.env` / `import.meta.env` reference from client code fails the build with an `EnvLeakageError`.
69
71
 
70
72
  ## Notes
71
73
 
72
- - Every field is currently **required** — there's no built-in `optional()`/`default()` wrapper. If a variable is genuinely optional in your app, read it from `process.env` directly rather than through `createEnv`, or write a validator whose `parse` returns a fallback instead of throwing on `undefined`.
74
+ - Every field is currently **required**; there's no built-in `optional()`/`default()` wrapper. If a variable is genuinely optional in your app, read it from `process.env` directly rather than through `createEnv`, or write a validator whose `parse` returns a fallback instead of throwing on `undefined`.
73
75
  - `runtimeEnv` is passed in explicitly (rather than read internally) so this works the same whether you're on Bun, in a bundler that inlines `process.env.*` at build time, or in a test with a mocked env object.
74
76
 
75
77
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thexjs/env",
3
- "version": "0.1.3",
3
+ "version": "1.0.0",
4
4
  "description": "Type-safe environment variable loading and validation for the x framework.",
5
5
  "keywords": ["environment-variables", "env", "validation", "typescript", "config", "bun", "x"],
6
6
  "license": "MIT",