envapt 6.0.0 → 6.0.1

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 (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +16 -12
  3. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # envapt
2
2
 
3
+ ## 6.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 40c3e4b: Reword the package description to lead with typed config from any source rather than .env loading, because that's what envapt is about and the .env cascade is just one feature of the default Node source.
8
+
3
9
  ## 6.0.0
4
10
 
5
11
  ### Major Changes
package/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  <h3>envapt</h3>
4
4
 
5
5
  <p>
6
- <strong>The apt way to handle environment variables.</strong><br/>
7
- Read them as typed values, with zero runtime dependencies.
6
+ <strong>The apt way to read typed config.</strong><br/>
7
+ Read config from any source as real typed values, with zero runtime dependencies.
8
8
  </p>
9
9
 
10
10
  <p>
@@ -17,9 +17,10 @@
17
17
 
18
18
  <br clear="left"/>
19
19
 
20
- `process.env` always hands you a `string | undefined`. envapt returns the type you asked for, with a
21
- fallback that removes `undefined` from the return type. On Node, Bun, and Deno it reads `process.env`
22
- and your `.env` files; on Cloudflare Workers and in the browser you bind the source with
20
+ envapt returns config as the type you asked for instead of the `string | undefined` you get raw, with
21
+ a fallback that removes `undefined` from the return type. It reads from whatever source you bind. On
22
+ Node, Bun, and Deno that is `process.env` and your `.env` files, bound on import. On Cloudflare
23
+ Workers, in the browser, or for a secrets object you fetched at boot, you bind the source with
23
24
  `Envapter.useSource(...)`.
24
25
 
25
26
  ```ts
@@ -35,14 +36,17 @@ const port = Envapter.getNumber('PORT', 3000); // number, not string | undefined
35
36
  - **Typed values.** A fallback removes `undefined` from the return type. Built-in converters cover
36
37
  numbers, booleans, bigint, JSON, URLs, regular expressions, dates, durations, and arrays, or pass
37
38
  your own function or a Standard Schema validator (zod, valibot, arktype).
38
- - **Zero runtime dependencies.** envapt ships its own `.env` parser, so nothing is added to your
39
- dependency tree.
39
+ - **Any source.** A source is any object with a `readVars()` method, so you can bind `process.env`, a
40
+ Cloudflare Workers binding, a browser bundle, or a secrets payload you fetched from a store at boot.
41
+ On Node, Bun, and Deno one binds on import.
42
+ - **Zero runtime dependencies.** The reader, converters, and built-in `.env` parser are self-contained,
43
+ so nothing is added to your dependency tree.
40
44
  - **Runs on Node, Bun, Deno, Cloudflare Workers, and the browser.** Node `>=20`, Bun `>=1.3`, Deno
41
- `>=2.5` (ESM and CJS); the Workers and browser builds resolve through the package `exports`
45
+ `>=2.5` (ESM and CJS). The Workers and browser builds resolve through the package `exports`
42
46
  conditions.
43
- - **`.env` loading on Node, Bun, and Deno.** A per-environment file cascade, `${VAR}` templates, and
44
- strict / required checks. Off Node there is no filesystem, so you bind a source with
45
- `Envapter.useSource(...)` and read with the same typed API.
47
+ - **`.env` loading built in on Node.** The default Node source adds a per-environment file cascade,
48
+ `${VAR}` templates, and strict / required checks. Off Node there is no filesystem, so you bind
49
+ another source with `Envapter.useSource(...)` and read with the same typed API.
46
50
 
47
51
  ## Install
48
52
 
@@ -62,7 +66,7 @@ Both share the same parsing, converters, and cache.
62
66
  ### Functional
63
67
 
64
68
  Read a value from any call site, in JavaScript or TypeScript. No build step. On Node the source is
65
- bound for you; on Workers and in the browser, call `Envapter.useSource(...)` first.
69
+ bound for you. On Workers and in the browser, call `Envapter.useSource(...)` first.
66
70
 
67
71
  ```ts
68
72
  import { Envapter, Converters } from 'envapt';
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "envapt",
3
3
  "type": "module",
4
- "version": "6.0.0",
5
- "description": "Type-safe environment variables for TypeScript. Zero-dependency .env loader and parser with one API across Node, Bun, Deno, Cloudflare Workers, and the Browser. Decorators, converters, Standard Schema (zod/valibot/arktype) validation, and much more.",
4
+ "version": "6.0.1",
5
+ "description": "Type-safe config for TypeScript. Read typed values from any source, process.env, .env files, Cloudflare Workers bindings, browser bundles, or any object you supply. Zero runtime dependencies, one API across Node, Bun, Deno, Workers, and the browser. Decorators, converters, and Standard Schema (zod/valibot/arktype) validation.",
6
6
  "types": "./dist/node/index.d.mts",
7
7
  "exports": {
8
8
  ".": {
@@ -146,5 +146,5 @@
146
146
  "bump": "pnpm tsx ../../scripts/bump-jsr.ts",
147
147
  "release": "pnpm run cs:publish"
148
148
  },
149
- "readme": "<img src=\"https://raw.githubusercontent.com/materwelonDhruv/envapt/main/.github/assets/logo.png\" width=\"120\" align=\"left\" alt=\"envapt logo\" />\n\n<h3>envapt</h3>\n\n<p>\n <strong>The apt way to handle environment variables.</strong><br/>\n Read them as typed values, with zero runtime dependencies.\n</p>\n\n<p>\n <a href=\"https://www.npmjs.com/package/envapt\"><img alt=\"npm\" src=\"https://img.shields.io/npm/v/envapt?logo=npm&logoColor=cb3838&label=%20&labelColor=103544&color=cb3838\"></a>\n <a href=\"https://www.npmjs.com/package/envapt\"><img alt=\"downloads\" src=\"https://img.shields.io/npm/dm/envapt?style=flat&color=f7f6e8&labelColor=103544&label=downloads\"></a>\n <a href=\"https://jsr.io/@materwelon/envapt\"><img alt=\"jsr\" src=\"https://jsr.io/badges/@materwelon/envapt\"></a>\n <img alt=\"CI\" src=\"https://img.shields.io/github/actions/workflow/status/materwelonDhruv/envapt/checks.yml?branch=main&label=tests&style=flat&logo=github&color=3fb950&labelColor=103544\">\n <a href=\"LICENSE\"><img alt=\"License\" src=\"https://img.shields.io/npm/l/envapt?style=flat&color=e97826&logo=apache&label=\"></a>\n</p>\n\n<br clear=\"left\"/>\n\n`process.env` always hands you a `string | undefined`. envapt returns the type you asked for, with a\nfallback that removes `undefined` from the return type. On Node, Bun, and Deno it reads `process.env`\nand your `.env` files; on Cloudflare Workers and in the browser you bind the source with\n`Envapter.useSource(...)`.\n\n```ts\nimport { Envapter } from 'envapt';\n\nconst port = Envapter.getNumber('PORT', 3000); // number, not string | undefined\n```\n\n**[Read the docs →](https://envapt.materwelon.dev)**\n\n## What you get\n\n- **Typed values.** A fallback removes `undefined` from the return type. Built-in converters cover\n numbers, booleans, bigint, JSON, URLs, regular expressions, dates, durations, and arrays, or pass\n your own function or a Standard Schema validator (zod, valibot, arktype).\n- **Zero runtime dependencies.** envapt ships its own `.env` parser, so nothing is added to your\n dependency tree.\n- **Runs on Node, Bun, Deno, Cloudflare Workers, and the browser.** Node `>=20`, Bun `>=1.3`, Deno\n `>=2.5` (ESM and CJS); the Workers and browser builds resolve through the package `exports`\n conditions.\n- **`.env` loading on Node, Bun, and Deno.** A per-environment file cascade, `${VAR}` templates, and\n strict / required checks. Off Node there is no filesystem, so you bind a source with\n `Envapter.useSource(...)` and read with the same typed API.\n\n## Install\n\n```sh\nnpm install envapt\npnpm add envapt\nyarn add envapt\nbun add envapt\ndeno add jsr:@materwelon/envapt\n```\n\n## Quick start\n\nRead values functionally with `Envapter`, or bind them to class fields with the `@Envapt` decorator.\nBoth share the same parsing, converters, and cache.\n\n### Functional\n\nRead a value from any call site, in JavaScript or TypeScript. No build step. On Node the source is\nbound for you; on Workers and in the browser, call `Envapter.useSource(...)` first.\n\n```ts\nimport { Envapter, Converters } from 'envapt';\n\nconst port = Envapter.getNumber('PORT', 3000);\nconst origins = Envapter.getUsing('ALLOWED_ORIGINS', Converters.array(), []);\n```\n\nOn Cloudflare Workers, `env` is importable at module scope, so bind it once in a config module; in the\nbrowser, seed a `ManualEnvSource` from the object your bundler injects.\n\n```ts\nimport { env } from 'cloudflare:workers';\nimport { Envapter, WorkerEnvSource } from 'envapt';\n\nEnvapter.useSource(new WorkerEnvSource(env));\n\nexport const apiToken = Envapter.get('API_TOKEN');\n```\n\n### Decorator\n\nBind a value to a class field. TypeScript, with `experimentalDecorators` in your `tsconfig.json`.\n\n```ts\nimport { Envapt, Converters } from 'envapt';\n\nclass Config {\n @Envapt('PORT', { converter: Converters.Number, fallback: 3000 })\n declare static readonly port: number;\n}\n```\n\n## Documentation\n\nThe guide, converter reference, validation, configuration, and the v4 to v5 migration live at\n**[envapt.materwelon.dev](https://envapt.materwelon.dev)**.\n\n## Agent skill\n\nInstall the envapt agent skill so AI coding tools use the correct API:\n\n```sh\nnpx skills add materwelonDhruv/envapt\n```\n\n---\n\n<p align=\"center\"><sub>Built by <a href=\"https://github.com/materwelondhruv\">@materwelonDhruv</a> · Apache 2.0</sub></p>\n"
149
+ "readme": "<img src=\"https://raw.githubusercontent.com/materwelonDhruv/envapt/main/.github/assets/logo.png\" width=\"120\" align=\"left\" alt=\"envapt logo\" />\n\n<h3>envapt</h3>\n\n<p>\n <strong>The apt way to read typed config.</strong><br/>\n Read config from any source as real typed values, with zero runtime dependencies.\n</p>\n\n<p>\n <a href=\"https://www.npmjs.com/package/envapt\"><img alt=\"npm\" src=\"https://img.shields.io/npm/v/envapt?logo=npm&logoColor=cb3838&label=%20&labelColor=103544&color=cb3838\"></a>\n <a href=\"https://www.npmjs.com/package/envapt\"><img alt=\"downloads\" src=\"https://img.shields.io/npm/dm/envapt?style=flat&color=f7f6e8&labelColor=103544&label=downloads\"></a>\n <a href=\"https://jsr.io/@materwelon/envapt\"><img alt=\"jsr\" src=\"https://jsr.io/badges/@materwelon/envapt\"></a>\n <img alt=\"CI\" src=\"https://img.shields.io/github/actions/workflow/status/materwelonDhruv/envapt/checks.yml?branch=main&label=tests&style=flat&logo=github&color=3fb950&labelColor=103544\">\n <a href=\"LICENSE\"><img alt=\"License\" src=\"https://img.shields.io/npm/l/envapt?style=flat&color=e97826&logo=apache&label=\"></a>\n</p>\n\n<br clear=\"left\"/>\n\nenvapt returns config as the type you asked for instead of the `string | undefined` you get raw, with\na fallback that removes `undefined` from the return type. It reads from whatever source you bind. On\nNode, Bun, and Deno that is `process.env` and your `.env` files, bound on import. On Cloudflare\nWorkers, in the browser, or for a secrets object you fetched at boot, you bind the source with\n`Envapter.useSource(...)`.\n\n```ts\nimport { Envapter } from 'envapt';\n\nconst port = Envapter.getNumber('PORT', 3000); // number, not string | undefined\n```\n\n**[Read the docs →](https://envapt.materwelon.dev)**\n\n## What you get\n\n- **Typed values.** A fallback removes `undefined` from the return type. Built-in converters cover\n numbers, booleans, bigint, JSON, URLs, regular expressions, dates, durations, and arrays, or pass\n your own function or a Standard Schema validator (zod, valibot, arktype).\n- **Any source.** A source is any object with a `readVars()` method, so you can bind `process.env`, a\n Cloudflare Workers binding, a browser bundle, or a secrets payload you fetched from a store at boot.\n On Node, Bun, and Deno one binds on import.\n- **Zero runtime dependencies.** The reader, converters, and built-in `.env` parser are self-contained,\n so nothing is added to your dependency tree.\n- **Runs on Node, Bun, Deno, Cloudflare Workers, and the browser.** Node `>=20`, Bun `>=1.3`, Deno\n `>=2.5` (ESM and CJS). The Workers and browser builds resolve through the package `exports`\n conditions.\n- **`.env` loading built in on Node.** The default Node source adds a per-environment file cascade,\n `${VAR}` templates, and strict / required checks. Off Node there is no filesystem, so you bind\n another source with `Envapter.useSource(...)` and read with the same typed API.\n\n## Install\n\n```sh\nnpm install envapt\npnpm add envapt\nyarn add envapt\nbun add envapt\ndeno add jsr:@materwelon/envapt\n```\n\n## Quick start\n\nRead values functionally with `Envapter`, or bind them to class fields with the `@Envapt` decorator.\nBoth share the same parsing, converters, and cache.\n\n### Functional\n\nRead a value from any call site, in JavaScript or TypeScript. No build step. On Node the source is\nbound for you. On Workers and in the browser, call `Envapter.useSource(...)` first.\n\n```ts\nimport { Envapter, Converters } from 'envapt';\n\nconst port = Envapter.getNumber('PORT', 3000);\nconst origins = Envapter.getUsing('ALLOWED_ORIGINS', Converters.array(), []);\n```\n\nOn Cloudflare Workers, `env` is importable at module scope, so bind it once in a config module; in the\nbrowser, seed a `ManualEnvSource` from the object your bundler injects.\n\n```ts\nimport { env } from 'cloudflare:workers';\nimport { Envapter, WorkerEnvSource } from 'envapt';\n\nEnvapter.useSource(new WorkerEnvSource(env));\n\nexport const apiToken = Envapter.get('API_TOKEN');\n```\n\n### Decorator\n\nBind a value to a class field. TypeScript, with `experimentalDecorators` in your `tsconfig.json`.\n\n```ts\nimport { Envapt, Converters } from 'envapt';\n\nclass Config {\n @Envapt('PORT', { converter: Converters.Number, fallback: 3000 })\n declare static readonly port: number;\n}\n```\n\n## Documentation\n\nThe guide, converter reference, validation, configuration, and the v4 to v5 migration live at\n**[envapt.materwelon.dev](https://envapt.materwelon.dev)**.\n\n## Agent skill\n\nInstall the envapt agent skill so AI coding tools use the correct API:\n\n```sh\nnpx skills add materwelonDhruv/envapt\n```\n\n---\n\n<p align=\"center\"><sub>Built by <a href=\"https://github.com/materwelondhruv\">@materwelonDhruv</a> · Apache 2.0</sub></p>\n"
150
150
  }