|
1 | 1 | # @danimydev/env |
2 | 2 |
|
3 | | -A TypeScript-first, runtime-safe environment variable reader. Works in Node.js, Deno, Bun, Browser, and Cloudflare Workers. |
| 3 | +A TypeScript-first, runtime-safe environment variable reader. Works in Node.js, |
| 4 | +Deno and Bun. If you want you can just copy the source code or install it via |
| 5 | +[jsr](https://jsr.io/@danimydev/env). |
4 | 6 |
|
5 | 7 | ## Usage |
| 8 | + |
6 | 9 | ```typescript |
7 | | -import env, { string, number, boolean, object, optional } from "@danimydev/env"; |
8 | | - |
9 | | -const config = env( |
10 | | - object({ |
11 | | - NODE_ENV: string(), |
12 | | - PORT: number(), |
13 | | - DEBUG: optional(boolean()) |
14 | | - }) |
15 | | -); |
16 | | - |
17 | | -console.log(config.NODE_ENV); |
18 | | -console.log(config.PORT); |
19 | | -console.log(config.DEBUG); |
| 10 | +import env, { boolean, number, optional, string } from "@danimydev/env"; |
| 11 | + |
| 12 | +const config = env({ |
| 13 | + NODE_ENV: string(), // string, |
| 14 | + PORT: number(), // number, |
| 15 | + DEBUG: optional(boolean()), // boolean | undefined |
| 16 | +}); |
20 | 17 | ``` |
21 | 18 |
|
22 | 19 | ## Highlights |
23 | 20 |
|
24 | 21 | - ✅ TypeScript-first: fully typed environment variable schemas. |
25 | | -- 🌍 Cross-runtime: works in Node.js, Deno, Bun, Browser, Cloudflare Workers. |
| 22 | +- 🌍 Cross-runtime: works in Node.js, Deno and Bun. |
26 | 23 | - 💡 Flexible: supports optional variables. |
27 | 24 | - ⚡ Lightweight: zero dependencies, minimal overhead. |
28 | 25 |
|
29 | 26 | ## License |
30 | 27 |
|
31 | | -This project is released into the public domain under [The Unlicense](https://unlicense.org). |
| 28 | +This project is released into the public domain under |
| 29 | +[The Unlicense](https://unlicense.org). |
32 | 30 |
|
33 | | -Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software for any purpose. |
| 31 | +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this |
| 32 | +software for any purpose. |
34 | 33 |
|
35 | | -If you like the project, feel free to ⭐ [@danimydev/env on GitHub](https://github.com/danimydev/env)! |
| 34 | +If you like the project, feel free to ⭐ |
| 35 | +[@danimydev/env on GitHub](https://github.com/danimydev/env)! |
0 commit comments