@vivekrajput/envvault 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/LICENSE +21 -0
- package/README.md +191 -0
- package/dist/index.d.mts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +132 -0
- package/dist/index.mjs +106 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vivek Rajput
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# 📦 envvault
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
🔐 Type-safe environment variable validation for Node.js & TypeScript
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="https://img.shields.io/npm/v/envvault.svg" />
|
|
9
|
+
<img src="https://img.shields.io/npm/dw/envvault.svg" />
|
|
10
|
+
<img src="https://img.shields.io/github/stars/twojokers2000/envvault?style=social" />
|
|
11
|
+
<img src="https://img.shields.io/badge/zero-dependency-true-green" />
|
|
12
|
+
<img src="https://img.shields.io/badge/typescript-ready-blue" />
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 🚨 The Problem
|
|
18
|
+
|
|
19
|
+
Using `process.env` directly is unsafe:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
const port = process.env.PORT; // string | undefined 😬
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
* ❌ No type safety
|
|
26
|
+
* ❌ No validation
|
|
27
|
+
* ❌ Runtime crashes
|
|
28
|
+
* ❌ Silent bugs
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## ✅ The Solution
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { env, number } from "envvault";
|
|
36
|
+
|
|
37
|
+
const config = env({
|
|
38
|
+
PORT: number(),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
config.PORT; // number ✅
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
👉 Fail fast. Stay safe. Ship confidently.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## ✨ Features
|
|
49
|
+
|
|
50
|
+
* 🔒 Type-safe environment variables
|
|
51
|
+
* ⚡ Runtime validation
|
|
52
|
+
* 🧠 Default values support
|
|
53
|
+
* 🧩 Optional variables support
|
|
54
|
+
* 💥 Clear error messages
|
|
55
|
+
* 📦 Zero dependencies
|
|
56
|
+
* 🚀 Framework agnostic
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 📦 Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm install envvault
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## ⚡ Quick Start
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { env, string, number, boolean } from "envvault";
|
|
72
|
+
|
|
73
|
+
const config = env({
|
|
74
|
+
DATABASE_URL: string(),
|
|
75
|
+
PORT: number().default(3000),
|
|
76
|
+
DEBUG: boolean().optional(),
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 🧠 Example
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const config = env({
|
|
86
|
+
API_KEY: string(),
|
|
87
|
+
PORT: number().default(3000),
|
|
88
|
+
NODE_ENV: string(),
|
|
89
|
+
DEBUG: boolean().optional(),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
console.log(config.PORT); // number
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 💥 Error Example
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
❌ Invalid environment variable: PORT must be a number
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
👉 Your app crashes early instead of failing in production.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 🆚 Comparison
|
|
108
|
+
|
|
109
|
+
| Feature | envvault | manual |
|
|
110
|
+
| ----------- | -------- | ------ |
|
|
111
|
+
| Type safety | ✅ | ❌ |
|
|
112
|
+
| Validation | ✅ | ❌ |
|
|
113
|
+
| Defaults | ✅ | ⚠️ |
|
|
114
|
+
| DX | 🔥 | ❌ |
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 📁 Example `.env`
|
|
119
|
+
|
|
120
|
+
```env
|
|
121
|
+
PORT=3000
|
|
122
|
+
DATABASE_URL=postgres://localhost:5432/db
|
|
123
|
+
DEBUG=true
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 🧩 API
|
|
129
|
+
|
|
130
|
+
### Validators
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
string()
|
|
134
|
+
number()
|
|
135
|
+
boolean()
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Modifiers
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
.optional()
|
|
142
|
+
.default(value)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 🛠 Development
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npm install
|
|
151
|
+
npm run build
|
|
152
|
+
npm test
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 🚀 Roadmap
|
|
158
|
+
|
|
159
|
+
* [ ] URL / enum validators
|
|
160
|
+
* [ ] CLI support
|
|
161
|
+
* [ ] Better error formatting
|
|
162
|
+
* [ ] Browser support
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 🤝 Contributing
|
|
167
|
+
|
|
168
|
+
PRs are welcome! Feel free to open issues or suggest improvements.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 📄 License
|
|
173
|
+
|
|
174
|
+
MIT © Vivek Kumar
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## ⭐ Support
|
|
179
|
+
|
|
180
|
+
If you like this project:
|
|
181
|
+
|
|
182
|
+
* ⭐ Star the repo
|
|
183
|
+
* 🐛 Report issues
|
|
184
|
+
* 💡 Suggest features
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## 🔥 One-line Pitch
|
|
189
|
+
|
|
190
|
+
> envvault = Zod for environment variables (zero dependency)
|
|
191
|
+
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type EnvType = "string" | "number" | "boolean" | "url" | "email" | "port";
|
|
2
|
+
interface EnvField<T = unknown> {
|
|
3
|
+
type: EnvType;
|
|
4
|
+
required?: boolean;
|
|
5
|
+
default?: T;
|
|
6
|
+
description?: string;
|
|
7
|
+
choices?: T[];
|
|
8
|
+
}
|
|
9
|
+
type EnvSchema = Record<string, EnvField>;
|
|
10
|
+
type InferEnvType<T extends EnvType> = T extends "number" | "port" ? number : T extends "boolean" ? boolean : string;
|
|
11
|
+
type InferSchema<S extends EnvSchema> = {
|
|
12
|
+
[K in keyof S]: S[K]["default"] extends NonNullable<S[K]["default"]> ? InferEnvType<S[K]["type"]> : S[K]["required"] extends false ? InferEnvType<S[K]["type"]> | undefined : InferEnvType<S[K]["type"]>;
|
|
13
|
+
};
|
|
14
|
+
declare class EnvValidationError extends Error {
|
|
15
|
+
readonly errors: string[];
|
|
16
|
+
constructor(errors: string[]);
|
|
17
|
+
}
|
|
18
|
+
declare function createEnv<S extends EnvSchema>(schema: S, source?: Record<string, string | undefined>): InferSchema<S>;
|
|
19
|
+
|
|
20
|
+
export { type EnvField, type EnvSchema, type EnvType, EnvValidationError, type InferEnvType, type InferSchema, createEnv };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type EnvType = "string" | "number" | "boolean" | "url" | "email" | "port";
|
|
2
|
+
interface EnvField<T = unknown> {
|
|
3
|
+
type: EnvType;
|
|
4
|
+
required?: boolean;
|
|
5
|
+
default?: T;
|
|
6
|
+
description?: string;
|
|
7
|
+
choices?: T[];
|
|
8
|
+
}
|
|
9
|
+
type EnvSchema = Record<string, EnvField>;
|
|
10
|
+
type InferEnvType<T extends EnvType> = T extends "number" | "port" ? number : T extends "boolean" ? boolean : string;
|
|
11
|
+
type InferSchema<S extends EnvSchema> = {
|
|
12
|
+
[K in keyof S]: S[K]["default"] extends NonNullable<S[K]["default"]> ? InferEnvType<S[K]["type"]> : S[K]["required"] extends false ? InferEnvType<S[K]["type"]> | undefined : InferEnvType<S[K]["type"]>;
|
|
13
|
+
};
|
|
14
|
+
declare class EnvValidationError extends Error {
|
|
15
|
+
readonly errors: string[];
|
|
16
|
+
constructor(errors: string[]);
|
|
17
|
+
}
|
|
18
|
+
declare function createEnv<S extends EnvSchema>(schema: S, source?: Record<string, string | undefined>): InferSchema<S>;
|
|
19
|
+
|
|
20
|
+
export { type EnvField, type EnvSchema, type EnvType, EnvValidationError, type InferEnvType, type InferSchema, createEnv };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
EnvValidationError: () => EnvValidationError,
|
|
24
|
+
createEnv: () => createEnv
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var EnvValidationError = class extends Error {
|
|
28
|
+
constructor(errors) {
|
|
29
|
+
super(`Environment validation failed:
|
|
30
|
+
${errors.map((e) => ` \u2716 ${e}`).join("\n")}`);
|
|
31
|
+
this.name = "EnvValidationError";
|
|
32
|
+
this.errors = errors;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function validateEmail(value) {
|
|
36
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
|
37
|
+
}
|
|
38
|
+
function validateUrl(value) {
|
|
39
|
+
try {
|
|
40
|
+
new URL(value);
|
|
41
|
+
return true;
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function validatePort(value) {
|
|
47
|
+
const num = Number(value);
|
|
48
|
+
return Number.isInteger(num) && num >= 1 && num <= 65535;
|
|
49
|
+
}
|
|
50
|
+
function coerce(value, type) {
|
|
51
|
+
switch (type) {
|
|
52
|
+
case "number":
|
|
53
|
+
return Number(value);
|
|
54
|
+
case "port":
|
|
55
|
+
return Number(value);
|
|
56
|
+
case "boolean":
|
|
57
|
+
return value.toLowerCase() === "true" || value === "1";
|
|
58
|
+
default:
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function createEnv(schema, source = process.env) {
|
|
63
|
+
const errors = [];
|
|
64
|
+
const result = {};
|
|
65
|
+
for (const [key, field] of Object.entries(schema)) {
|
|
66
|
+
const rawValue = source[key];
|
|
67
|
+
const isRequired = field.required !== false;
|
|
68
|
+
if (rawValue === void 0 || rawValue === "") {
|
|
69
|
+
if (field.default !== void 0) {
|
|
70
|
+
result[key] = field.default;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (isRequired) {
|
|
74
|
+
errors.push(
|
|
75
|
+
`Missing required variable "${key}"${field.description ? ` (${field.description})` : ""}`
|
|
76
|
+
);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
result[key] = void 0;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
switch (field.type) {
|
|
83
|
+
case "number":
|
|
84
|
+
if (isNaN(Number(rawValue))) {
|
|
85
|
+
errors.push(`"${key}" must be a valid number, got "${rawValue}"`);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case "port":
|
|
90
|
+
if (!validatePort(rawValue)) {
|
|
91
|
+
errors.push(`"${key}" must be a valid port (1\u201365535), got "${rawValue}"`);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
case "boolean":
|
|
96
|
+
if (!["true", "false", "1", "0"].includes(rawValue.toLowerCase())) {
|
|
97
|
+
errors.push(`"${key}" must be true/false/1/0, got "${rawValue}"`);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
case "email":
|
|
102
|
+
if (!validateEmail(rawValue)) {
|
|
103
|
+
errors.push(`"${key}" must be a valid email, got "${rawValue}"`);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case "url":
|
|
108
|
+
if (!validateUrl(rawValue)) {
|
|
109
|
+
errors.push(`"${key}" must be a valid URL, got "${rawValue}"`);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
const coerced = coerce(rawValue, field.type);
|
|
115
|
+
if (field.choices && !field.choices.includes(coerced)) {
|
|
116
|
+
errors.push(
|
|
117
|
+
`"${key}" must be one of [${field.choices.join(", ")}], got "${rawValue}"`
|
|
118
|
+
);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
result[key] = coerced;
|
|
122
|
+
}
|
|
123
|
+
if (errors.length > 0) {
|
|
124
|
+
throw new EnvValidationError(errors);
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
+
0 && (module.exports = {
|
|
130
|
+
EnvValidationError,
|
|
131
|
+
createEnv
|
|
132
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var EnvValidationError = class extends Error {
|
|
3
|
+
constructor(errors) {
|
|
4
|
+
super(`Environment validation failed:
|
|
5
|
+
${errors.map((e) => ` \u2716 ${e}`).join("\n")}`);
|
|
6
|
+
this.name = "EnvValidationError";
|
|
7
|
+
this.errors = errors;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function validateEmail(value) {
|
|
11
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
|
12
|
+
}
|
|
13
|
+
function validateUrl(value) {
|
|
14
|
+
try {
|
|
15
|
+
new URL(value);
|
|
16
|
+
return true;
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function validatePort(value) {
|
|
22
|
+
const num = Number(value);
|
|
23
|
+
return Number.isInteger(num) && num >= 1 && num <= 65535;
|
|
24
|
+
}
|
|
25
|
+
function coerce(value, type) {
|
|
26
|
+
switch (type) {
|
|
27
|
+
case "number":
|
|
28
|
+
return Number(value);
|
|
29
|
+
case "port":
|
|
30
|
+
return Number(value);
|
|
31
|
+
case "boolean":
|
|
32
|
+
return value.toLowerCase() === "true" || value === "1";
|
|
33
|
+
default:
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function createEnv(schema, source = process.env) {
|
|
38
|
+
const errors = [];
|
|
39
|
+
const result = {};
|
|
40
|
+
for (const [key, field] of Object.entries(schema)) {
|
|
41
|
+
const rawValue = source[key];
|
|
42
|
+
const isRequired = field.required !== false;
|
|
43
|
+
if (rawValue === void 0 || rawValue === "") {
|
|
44
|
+
if (field.default !== void 0) {
|
|
45
|
+
result[key] = field.default;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (isRequired) {
|
|
49
|
+
errors.push(
|
|
50
|
+
`Missing required variable "${key}"${field.description ? ` (${field.description})` : ""}`
|
|
51
|
+
);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
result[key] = void 0;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
switch (field.type) {
|
|
58
|
+
case "number":
|
|
59
|
+
if (isNaN(Number(rawValue))) {
|
|
60
|
+
errors.push(`"${key}" must be a valid number, got "${rawValue}"`);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case "port":
|
|
65
|
+
if (!validatePort(rawValue)) {
|
|
66
|
+
errors.push(`"${key}" must be a valid port (1\u201365535), got "${rawValue}"`);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case "boolean":
|
|
71
|
+
if (!["true", "false", "1", "0"].includes(rawValue.toLowerCase())) {
|
|
72
|
+
errors.push(`"${key}" must be true/false/1/0, got "${rawValue}"`);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case "email":
|
|
77
|
+
if (!validateEmail(rawValue)) {
|
|
78
|
+
errors.push(`"${key}" must be a valid email, got "${rawValue}"`);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
case "url":
|
|
83
|
+
if (!validateUrl(rawValue)) {
|
|
84
|
+
errors.push(`"${key}" must be a valid URL, got "${rawValue}"`);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
const coerced = coerce(rawValue, field.type);
|
|
90
|
+
if (field.choices && !field.choices.includes(coerced)) {
|
|
91
|
+
errors.push(
|
|
92
|
+
`"${key}" must be one of [${field.choices.join(", ")}], got "${rawValue}"`
|
|
93
|
+
);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
result[key] = coerced;
|
|
97
|
+
}
|
|
98
|
+
if (errors.length > 0) {
|
|
99
|
+
throw new EnvValidationError(errors);
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
EnvValidationError,
|
|
105
|
+
createEnv
|
|
106
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vivekrajput/envvault",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Type-safe, zero-dependency environment variable validator for Node.js & TypeScript",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"test:watch": "vitest",
|
|
19
|
+
"lint": "tsc --noEmit",
|
|
20
|
+
"prepublishOnly": "npm run build && npm test"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"env",
|
|
24
|
+
"environment",
|
|
25
|
+
"validation",
|
|
26
|
+
"typescript",
|
|
27
|
+
"type-safe",
|
|
28
|
+
"dotenv",
|
|
29
|
+
"config",
|
|
30
|
+
"zero-dependency"
|
|
31
|
+
],
|
|
32
|
+
"author": "Vivek Rajput",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/twojokers2000/envvault"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/twojokers2000/envvault#readme",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/twojokers2000/envvault/issues"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^25.6.0",
|
|
44
|
+
"tsup": "^8.0.0",
|
|
45
|
+
"typescript": "^5.0.0",
|
|
46
|
+
"vitest": "^1.0.0"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"README.md",
|
|
51
|
+
"LICENSE"
|
|
52
|
+
],
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=18"
|
|
55
|
+
}
|
|
56
|
+
}
|