@thexjs/env 1.1.0 → 1.1.2
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.
- package/README.md +10 -10
- package/dist/validators.d.ts +2 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,8 +26,8 @@ export const env = createEnv({
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
env.DATABASE_URL; // string, validated as a URL
|
|
29
|
-
env.PORT;
|
|
30
|
-
env.NODE_ENV;
|
|
29
|
+
env.PORT; // number
|
|
30
|
+
env.NODE_ENV; // "development" | "production" | "test"
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
If any variable is missing or fails validation, `createEnv` throws a single `Error` listing every failure at once:
|
|
@@ -40,13 +40,13 @@ Environment validation failed:
|
|
|
40
40
|
|
|
41
41
|
## Validators
|
|
42
42
|
|
|
43
|
-
| Validator
|
|
44
|
-
|
|
45
|
-
| `str()`
|
|
46
|
-
| `num()`
|
|
47
|
-
| `bool()`
|
|
48
|
-
| `oneOf([...values])` | one of the given string literals
|
|
49
|
-
| `url()`
|
|
43
|
+
| Validator | Accepts | Notes |
|
|
44
|
+
| -------------------- | ------------------------------------------------------ | -------------------------------------------- |
|
|
45
|
+
| `str()` | any non-`undefined` string | |
|
|
46
|
+
| `num()` | numeric strings | rejects `NaN` |
|
|
47
|
+
| `bool()` | `"true"` / `"1"` → `true`, `"false"` / `"0"` → `false` | anything else throws |
|
|
48
|
+
| `oneOf([...values])` | one of the given string literals | return type is narrowed to the literal union |
|
|
49
|
+
| `url()` | any string parseable by `new URL(...)` | |
|
|
50
50
|
|
|
51
51
|
Built-in validators also expose two chaining combinators:
|
|
52
52
|
|
|
@@ -96,4 +96,4 @@ When used with `@thexjs/core`, keep the default `THEXJS_PUBLIC_` prefix: the fra
|
|
|
96
96
|
|
|
97
97
|
## License
|
|
98
98
|
|
|
99
|
-
MIT
|
|
99
|
+
MIT
|
package/dist/validators.d.ts
CHANGED
|
@@ -28,4 +28,5 @@ declare function bool(): ScalarValidator<boolean>;
|
|
|
28
28
|
declare function oneOf<T extends string>(values: readonly T[]): ScalarValidator<T>;
|
|
29
29
|
declare function url(): ScalarValidator<string>;
|
|
30
30
|
|
|
31
|
-
export {
|
|
31
|
+
export { bool, num, oneOf, str, url };
|
|
32
|
+
export type { ChainableValidator, EnvValidator };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thexjs/env",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Type-safe environment variable loading and validation for the x framework.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"environment-variables",
|
|
@@ -43,6 +43,6 @@
|
|
|
43
43
|
"typescript": "^5.7.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"tsup": "^
|
|
46
|
+
"tsup": "^9.0.0"
|
|
47
47
|
}
|
|
48
48
|
}
|