@quintal/environment 0.2.0 โ 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.
- package/.dist/index.cjs +1 -1
- package/.dist/index.d.ts +4 -4
- package/.dist/index.mjs +1081 -961
- package/README.md +15 -72
- package/package.json +15 -17
package/README.md
CHANGED
|
@@ -9,18 +9,25 @@ TO EDIT THE CONTENT, PLEASE MODIFY `/workspace.ts` OR `/scripts/generate.ts`
|
|
|
9
9
|
[](https://npmjs.com/@quintal/environment)
|
|
10
10
|
[](https://github.com/quintalwebsolutions/quintal-oss/blob/main/LICENSE)
|
|
11
11
|
[](https://bundlephobia.com/package/@quintal/environment)
|
|
12
|
-
[](https://libraries.io/npm/%40quintal%2Fenvironment/)
|
|
13
12
|
[](https://codecov.io/gh/quintalwebsolutions/quintal-oss)
|
|
14
13
|
[](https://github.com/quintalwebsolutions/quintal-oss/blob/main/CONTRIBUTING.md)
|
|
15
14
|
|
|
16
|
-
Framework-agnostic environment variable validation for TypeScript
|
|
15
|
+
Framework-agnostic environment variable validation for TypeScript powered by Zod
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- ๐ Use Zod to validate and transform environment variables,
|
|
20
|
+
- ๐ Secure environment variables by marking them as server-only,
|
|
21
|
+
- ๐ฆ Nest environment variables into groups,
|
|
22
|
+
- โ
CommonJS and ES Modules support,
|
|
23
|
+
- โ๏ธ Super lightweight (only ~10kb gzipped),
|
|
24
|
+
- ๐งช 100% test coverage,
|
|
25
|
+
- ๐ก๏ธ Enjoy full type-safety in every step of the process.
|
|
19
26
|
|
|
20
27
|
## Table of Contents
|
|
21
28
|
|
|
22
29
|
- [Getting Started](#getting-started)
|
|
23
|
-
- [
|
|
30
|
+
- [Examples](#examples)
|
|
24
31
|
|
|
25
32
|
## Getting Started
|
|
26
33
|
|
|
@@ -34,74 +41,10 @@ yarn add @quintal/environment
|
|
|
34
41
|
npm install @quintal/environment
|
|
35
42
|
```
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
## Kitchen Sink Example
|
|
44
|
+
## Examples
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
export const environment = createEnvironment({
|
|
43
|
-
values: {
|
|
44
|
-
environment: {
|
|
45
|
-
value: process.env.NEXT_PUBLIC_ENVIRONMENT,
|
|
46
|
-
schema: z
|
|
47
|
-
.enum(['DEVELOPMENT', 'PREVIEW', 'PRODUCTION'])
|
|
48
|
-
.default('DEVELOPMENT'),
|
|
49
|
-
},
|
|
50
|
-
port: {
|
|
51
|
-
value: process.env.PORT,
|
|
52
|
-
schema: z.coerce.number().int().default(4000),
|
|
53
|
-
isServerOnly: true,
|
|
54
|
-
},
|
|
55
|
-
simpleStringValue: process.env.SIMPLE_STRING_VALUE,
|
|
56
|
-
isFeatureEnabled: {
|
|
57
|
-
value: process.env.IS_FEATURE_ENABLED,
|
|
58
|
-
schema: z.enum(['true', 'false']).transform((s) => s === 'true'),
|
|
59
|
-
},
|
|
60
|
-
baseUrl: {
|
|
61
|
-
self: {
|
|
62
|
-
value: process.env.NEXT_PUBLIC_BASE_URL_SELF,
|
|
63
|
-
schema: z.string().url().default('http://localhost:3000'),
|
|
64
|
-
},
|
|
65
|
-
api: {
|
|
66
|
-
value: process.env.NEXT_PUBLIC_BASE_URL_API,
|
|
67
|
-
schema: z.string().url().default('http://localhost:4000'),
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
database: {
|
|
71
|
-
url: {
|
|
72
|
-
value: process.env.DATABASE_URL,
|
|
73
|
-
schema: z.string().url(),
|
|
74
|
-
isServerOnly: true,
|
|
75
|
-
},
|
|
76
|
-
token: {
|
|
77
|
-
value: process.env.DATABASE_TOKEN,
|
|
78
|
-
isServerOnly: true,
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
```
|
|
46
|
+
Check out these examples to get started quickly:
|
|
84
47
|
|
|
85
|
-
|
|
48
|
+
- [Kitchen sink](https://codesandbox.io/p/sandbox/x2slnv?file=%2Findex.ts)
|
|
86
49
|
|
|
87
|
-
|
|
88
|
-
type EnvValue = {
|
|
89
|
-
/**
|
|
90
|
-
* The value
|
|
91
|
-
* @example process.env.NODE_ENV
|
|
92
|
-
* @example process.env.DATABASE_URL
|
|
93
|
-
* @example process.env.NEXT_PUBLIC_ENVIRONMENT
|
|
94
|
-
*/
|
|
95
|
-
value: string | undefined;
|
|
96
|
-
/**
|
|
97
|
-
* Zod schema that validates the value of the environment variable.
|
|
98
|
-
* @defaultValue z.string()
|
|
99
|
-
*/
|
|
100
|
-
schema?: ZodType;
|
|
101
|
-
/**
|
|
102
|
-
* Only make environment variable available for server-side usage.
|
|
103
|
-
* @defaultValue false
|
|
104
|
-
*/
|
|
105
|
-
isServerOnly?: boolean;
|
|
106
|
-
};
|
|
107
|
-
```
|
|
50
|
+
<!-- END AUTO-GENERATED: Add custom documentation after this comment -->
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quintal/environment",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "Framework-agnostic environment variable validation for TypeScript",
|
|
5
|
+
"description": "Framework-agnostic environment variable validation for TypeScript powered by Zod",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"environment",
|
|
8
8
|
"validation",
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
".dist"
|
|
29
29
|
],
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"zod": "^3.
|
|
31
|
+
"zod": "^3.23.8"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@vitest/coverage-v8": "
|
|
36
|
-
"happy-dom": "
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"vite": "5.
|
|
40
|
-
"vitest": "
|
|
41
|
-
"zod": "3.
|
|
42
|
-
"@quintal/config": "0.2.
|
|
34
|
+
"@biomejs/biome": "1.8.3",
|
|
35
|
+
"@vitest/coverage-v8": "2.0.5",
|
|
36
|
+
"happy-dom": "15.7.3",
|
|
37
|
+
"npm-run-all": "4.1.5",
|
|
38
|
+
"shx": "0.3.4",
|
|
39
|
+
"vite": "5.4.2",
|
|
40
|
+
"vitest": "2.0.5",
|
|
41
|
+
"zod": "3.23.8",
|
|
42
|
+
"@quintal/config": "0.2.1"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "run-s build:*",
|
|
@@ -48,11 +48,9 @@
|
|
|
48
48
|
"clean": "shx rm -rf .coverage .coverage-ts .dist .turbo node_modules",
|
|
49
49
|
"dev": "vitest --watch",
|
|
50
50
|
"lint": "pnpm lint:fix && pnpm lint:types",
|
|
51
|
-
"lint:check": "biome ci
|
|
52
|
-
"lint:fix": "biome check --
|
|
51
|
+
"lint:check": "biome ci",
|
|
52
|
+
"lint:fix": "biome check --write",
|
|
53
53
|
"lint:types": "tsc --noEmit",
|
|
54
|
-
"test": "
|
|
55
|
-
"test:source": "vitest",
|
|
56
|
-
"test:types": "typescript-coverage-report --outputDir .coverage-ts --strict"
|
|
54
|
+
"test": "vitest"
|
|
57
55
|
}
|
|
58
56
|
}
|