@bb-labs/zod-env 0.0.1 → 0.0.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.
Files changed (2) hide show
  1. package/README.md +35 -7
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,15 +1,43 @@
1
- # zod-env
1
+ ## Introduction
2
2
 
3
- To install dependencies:
3
+ Type-safe environment variable validation using [Zod](https://zod.dev).
4
+
5
+ ## Installation
4
6
 
5
7
  ```bash
6
- bun install
8
+ npm install @bb-labs/zod-env
7
9
  ```
8
10
 
9
- To run:
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { zEnv } from "@bb-labs/zod-env";
15
+ import { z } from "zod";
16
+
17
+ const env = zEnv(process.env, {
18
+ DATABASE_URL: z.string().url(),
19
+ PORT: z.coerce.number().default(3000),
20
+ NODE_ENV: z.enum(["development", "production", "test"]),
21
+ DEBUG: z.string().optional(),
22
+ });
23
+
24
+ // Fully typed!
25
+ env.DATABASE_URL; // string
26
+ env.PORT; // number
27
+ env.NODE_ENV; // "development" | "production" | "test"
28
+ env.DEBUG; // string | undefined
29
+ ```
30
+
31
+ ## Error Handling
32
+
33
+ If validation fails, `zEnv` throws an error with all validation issues:
10
34
 
11
- ```bash
12
- bun run index.ts
13
35
  ```
36
+ Error: Environment validation failed:
37
+ DATABASE_URL: Invalid url
38
+ NODE_ENV: Invalid enum value. Expected 'development' | 'production' | 'test', received 'staging'
39
+ ```
40
+
41
+ ## License
14
42
 
15
- This project was created using `bun init` in bun v1.3.5. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
43
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bb-labs/zod-env",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "A library for parsing environment variables using Zod",
5
5
  "homepage": "https://github.com/beepbop-labs/zod-env",
6
6
  "keywords": [