arkenv 0.7.1 → 0.7.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 +14 -12
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
</p>
|
|
15
15
|
<h3 align="center">Proud member of the <a href="https://arktype.io/docs/ecosystem#arkenv">ArkType ecosystem</a></h3>
|
|
16
16
|
|
|
17
|
+
<p align="center">
|
|
18
|
+
<img alt="ArkEnv Demo" src="https://arkenv.js.org/assets/demo.gif" />
|
|
19
|
+
</p>
|
|
20
|
+
|
|
17
21
|
<br/>
|
|
18
22
|
<br/>
|
|
19
23
|
<br/>
|
|
@@ -23,12 +27,13 @@
|
|
|
23
27
|
<br/>
|
|
24
28
|
<br/>
|
|
25
29
|
|
|
26
|
-
## Introduction
|
|
30
|
+
## Introduction
|
|
27
31
|
|
|
32
|
+
> [!TIP]
|
|
33
|
+
> 📖 **Reading this on GitHub?** Check out [this page in our docs](https://arkenv.js.org/docs) to hover over code blocks and get type hints!
|
|
28
34
|
|
|
29
35
|
ArkEnv is an environment variable parser powered by [ArkType](https://arktype.io/), TypeScript's 1:1 validator. ArkEnv lets you use familiar TypeScript-like syntax to create a ready to use, typesafe environment variable object:
|
|
30
36
|
|
|
31
|
-
|
|
32
37
|
```ts twoslash
|
|
33
38
|
import arkenv from 'arkenv';
|
|
34
39
|
|
|
@@ -38,12 +43,10 @@ const env = arkenv({
|
|
|
38
43
|
NODE_ENV: "'development' | 'production' | 'test'",
|
|
39
44
|
});
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
console.log(env.PORT); // (property) PORT: number
|
|
46
|
-
console.log(env.NODE_ENV); // (property) NODE_ENV: "development" | "production" | "test"
|
|
46
|
+
// Hover to see ✨exact✨ types
|
|
47
|
+
const host = env.HOST;
|
|
48
|
+
const port = env.PORT;
|
|
49
|
+
const nodeEnv = env.NODE_ENV;
|
|
47
50
|
```
|
|
48
51
|
|
|
49
52
|
With ArkEnv, your environment variables are **guaranteed to match your schema**. If any variable is incorrect or missing, the app won't start and a clear error will be thrown:
|
|
@@ -61,7 +64,9 @@ ArkEnvError: Errors found while validating environment variables
|
|
|
61
64
|
- Tiny: <1kB gzipped
|
|
62
65
|
- Build-time and runtime validation
|
|
63
66
|
- Single import, zero config for most projects
|
|
67
|
+
- Validated, defaultable, typesafe environment variables
|
|
64
68
|
- Powered by ArkType, TypeScript's 1:1 validator
|
|
69
|
+
- Optimized from editor to runtime
|
|
65
70
|
|
|
66
71
|
## Installation
|
|
67
72
|
|
|
@@ -99,11 +104,8 @@ bun add arkenv arktype
|
|
|
99
104
|
|
|
100
105
|
:rocket: **Let's get started!** Read the [2-minute setup guide](https://arkenv.js.org/docs/quickstart) or [start with an example](https://arkenv.js.org/docs/examples).
|
|
101
106
|
|
|
102
|
-
|
|
103
107
|
> [!TIP]
|
|
104
|
-
> Improve your DX with syntax highlighting in [VS Code & Cursor](/docs/integrations/vscode) or [JetBrains IDEs](/docs/integrations/jetbrains).
|
|
105
|
-
>
|
|
106
|
-
> 
|
|
108
|
+
> Improve your DX with *syntax highlighting* in [VS Code & Cursor](https://arkenv.js.org/docs/integrations/vscode) or [JetBrains IDEs](https://arkenv.js.org/docs/integrations/jetbrains).
|
|
107
109
|
|
|
108
110
|
## Requirements
|
|
109
111
|
|
package/dist/index.d.cts
CHANGED
|
@@ -81,6 +81,10 @@ declare const $: arktype.Scope<{
|
|
|
81
81
|
|
|
82
82
|
type RuntimeEnvironment = Record<string, string | undefined>;
|
|
83
83
|
type EnvSchema<def> = type$1.validate<def, (typeof $)["t"]>;
|
|
84
|
+
/**
|
|
85
|
+
* TODO: If possible, find a better type than "const T extends Record<string, unknown>",
|
|
86
|
+
* and be as close as possible to the type accepted by ArkType's `type`.
|
|
87
|
+
*/
|
|
84
88
|
/**
|
|
85
89
|
* Create an environment variables object from a schema and an environment
|
|
86
90
|
* @param def - The environment variable schema
|
|
@@ -88,7 +92,7 @@ type EnvSchema<def> = type$1.validate<def, (typeof $)["t"]>;
|
|
|
88
92
|
* @returns The validated environment variable schema
|
|
89
93
|
* @throws An {@link ArkEnvError | error} if the environment variables are invalid.
|
|
90
94
|
*/
|
|
91
|
-
declare function createEnv<const T extends Record<string,
|
|
95
|
+
declare function createEnv<const T extends Record<string, unknown>>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>>;
|
|
92
96
|
|
|
93
97
|
declare const type: arktype_internal_type_ts.TypeParser<{
|
|
94
98
|
string: arktype.Submodule<{
|
package/dist/index.d.ts
CHANGED
|
@@ -81,6 +81,10 @@ declare const $: arktype.Scope<{
|
|
|
81
81
|
|
|
82
82
|
type RuntimeEnvironment = Record<string, string | undefined>;
|
|
83
83
|
type EnvSchema<def> = type$1.validate<def, (typeof $)["t"]>;
|
|
84
|
+
/**
|
|
85
|
+
* TODO: If possible, find a better type than "const T extends Record<string, unknown>",
|
|
86
|
+
* and be as close as possible to the type accepted by ArkType's `type`.
|
|
87
|
+
*/
|
|
84
88
|
/**
|
|
85
89
|
* Create an environment variables object from a schema and an environment
|
|
86
90
|
* @param def - The environment variable schema
|
|
@@ -88,7 +92,7 @@ type EnvSchema<def> = type$1.validate<def, (typeof $)["t"]>;
|
|
|
88
92
|
* @returns The validated environment variable schema
|
|
89
93
|
* @throws An {@link ArkEnvError | error} if the environment variables are invalid.
|
|
90
94
|
*/
|
|
91
|
-
declare function createEnv<const T extends Record<string,
|
|
95
|
+
declare function createEnv<const T extends Record<string, unknown>>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>>;
|
|
92
96
|
|
|
93
97
|
declare const type: arktype_internal_type_ts.TypeParser<{
|
|
94
98
|
string: arktype.Submodule<{
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkenv",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.2",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"author": "Yam Borodetsky <yam@yam.codes>",
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@ark/schema": "^0.49.0",
|
|
35
|
-
"@types/node": "24.
|
|
35
|
+
"@types/node": "24.6.2",
|
|
36
36
|
"tsup": "^8.5.0",
|
|
37
|
-
"typescript": "^5.9.
|
|
37
|
+
"typescript": "^5.9.3"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"arktype": "^2.1.22"
|