@lacspace/env 1.0.0 → 1.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 (3) hide show
  1. package/LICENSE +45 -15
  2. package/README.md +91 -0
  3. package/package.json +2 -2
package/LICENSE CHANGED
@@ -1,21 +1,51 @@
1
- MIT License
1
+ Lacspace Free Licence
2
+ Version 1.0, August 2026
2
3
 
3
4
  Copyright (c) 2026 Lacspace
4
5
 
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:
6
+ PREAMBLE
11
7
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
8
+ This software is published by Lacspace under the Lacspace Free Licence a free,
9
+ permissive licence that lets you use this software for any purpose, including in
10
+ commercial products and services, at no cost. It grants the same freedoms as
11
+ common permissive open-source licences; the only condition is that this notice
12
+ travels with the software. The canonical, always-current text of this licence is
13
+ maintained at https://lacspace.com/licenses/lacspace-free-1.0
14
+
15
+ GRANT OF RIGHTS
16
+
17
+ Permission is hereby granted, free of charge, to any person or organisation
18
+ obtaining a copy of this software and its associated documentation and data files
19
+ (the "Software"), to deal in the Software without restriction, including without
20
+ limitation the rights to use, copy, modify, merge, publish, distribute,
21
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the
22
+ Software is furnished to do so, subject to the conditions below. These rights are
23
+ granted for any purpose, personal or commercial, and are perpetual, worldwide,
24
+ non-exclusive, and royalty-free.
25
+
26
+ CONDITIONS
27
+
28
+ The above copyright notice, this permission notice, and the name of this licence
29
+ ("Lacspace Free Licence") shall be included in all copies or substantial portions
30
+ of the Software.
31
+
32
+ TRADEMARKS
33
+
34
+ This licence does not grant permission to use the trade names, trademarks, service
35
+ marks, logos, or product names of Lacspace, except as required to reproduce the
36
+ notice above or to describe the origin of the Software in a truthful manner.
37
+
38
+ DISCLAIMER OF WARRANTY AND LIMITATION OF LIABILITY
14
39
 
15
40
  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.
41
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
42
+ FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
43
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN
44
+ AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
45
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46
+
47
+ ---
48
+
49
+ The Lacspace Free Licence is a source-available, permissive licence and is not (as
50
+ of this version) an OSI-approved licence. In substance it grants the same freedoms
51
+ as the MIT Licence. Learn more at https://lacspace.com/licenses
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ <div align="center">
2
+
3
+ # @lacspace/env
4
+
5
+ **Typed, validated environment variables — fail fast at boot, not in production.**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@lacspace/env?color=%230ea5e9&label=npm)](https://www.npmjs.com/package/@lacspace/env)
8
+ [![install size](https://packagephobia.com/badge?p=@lacspace/env)](https://packagephobia.com/result?p=@lacspace/env)
9
+ [![minzipped](https://img.shields.io/bundlephobia/minzip/@lacspace/env?label=minzip)](https://bundlephobia.com/package/@lacspace/env)
10
+ [![types](https://img.shields.io/badge/types-included-blue)](https://www.npmjs.com/package/@lacspace/env)
11
+ [![license](https://img.shields.io/npm/l/@lacspace/env?color=green)](https://github.com/lacspace/npm-packages/blob/main/LICENSE)
12
+
13
+ </div>
14
+
15
+ > Declare a schema, validate `process.env` once at startup, and get a **typed, frozen** object. Missing or malformed variables throw **one clear error listing everything wrong** — so a bad deploy fails immediately instead of 500-ing at 2am. A zero-dependency [t3-env](https://env.t3.gg) / [envalid](https://github.com/af/envalid) alternative.
16
+
17
+ - 🔒 Types inferred from the schema — `env.PORT` is a `number`, guaranteed present
18
+ - 💥 Fail-fast with an aggregated, readable error
19
+ - 🧰 Validators: `str` · `num` · `int` · `port` · `bool` · `url` · `email` · `oneOf` · `json`
20
+ - 🎚️ `default`, `optional`, `min`/`max` per field
21
+ - ⚡ Zero dependencies · 🌍 isomorphic · 📦 ESM + CJS · fully typed
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ npm install @lacspace/env # or pnpm add / yarn add / bun add
27
+ ```
28
+
29
+ ## Define once, use everywhere
30
+
31
+ ```ts
32
+ // env.ts
33
+ import { createEnv, str, port, url, bool, oneOf } from "@lacspace/env";
34
+
35
+ export const env = createEnv({
36
+ NODE_ENV: oneOf(["development", "production", "test"], { default: "development" }),
37
+ PORT: port({ default: 3000 }),
38
+ DATABASE_URL: url(),
39
+ SMTP_HOST: str(),
40
+ SMTP_PORT: port({ default: 587 }),
41
+ DEBUG: bool({ default: false }),
42
+ ADMIN_EMAILS: str({ optional: true }),
43
+ });
44
+ ```
45
+
46
+ ```ts
47
+ import { env } from "./env";
48
+
49
+ env.PORT; // number — 3000 unless set
50
+ env.DEBUG; // boolean
51
+ env.NODE_ENV; // "development" | "production" | "test"
52
+ ```
53
+
54
+ If `DATABASE_URL` is missing and `SMTP_PORT` is `"abc"`, startup throws:
55
+
56
+ ```
57
+ EnvError: Invalid environment variables:
58
+ • "DATABASE_URL" is required but was not set
59
+ • "SMTP_PORT" must be a number, got "abc"
60
+ ```
61
+
62
+ ## Validators
63
+
64
+ | Validator | Parses to | Options |
65
+ | --- | --- | --- |
66
+ | `str(opts?)` | string | `default`, `optional`, `allowEmpty` |
67
+ | `num` / `int` | number | `default`, `optional`, `min`, `max` |
68
+ | `port(opts?)` | number (1–65535) | `default`, `optional` |
69
+ | `bool(opts?)` | boolean | accepts `true/1/yes/on`, `false/0/no/off` |
70
+ | `url` / `email` | validated string | `default`, `optional` |
71
+ | `oneOf(values, opts?)` | union of literals | `default`, `optional` |
72
+ | `json<T>(opts?)` | parsed JSON | `default`, `optional` |
73
+
74
+ ## Not just `process.env`
75
+
76
+ ```ts
77
+ createEnv(schema, import.meta.env); // Vite
78
+ createEnv(schema, Deno.env.toObject());
79
+ ```
80
+
81
+ ## The Lacspace WebKit
82
+
83
+ | Package | For |
84
+ | --- | --- |
85
+ | [`@lacspace/seo`](https://www.npmjs.com/package/@lacspace/seo) | Metadata & JSON-LD |
86
+ | **`@lacspace/env`** | Typed env variables (this package) |
87
+ | [`@lacspace/rate-limit`](https://www.npmjs.com/package/@lacspace/rate-limit) | Rate limiting |
88
+ | [`@lacspace/otp`](https://www.npmjs.com/package/@lacspace/otp) | TOTP/HOTP 2FA |
89
+ | [`@lacspace/next`](https://www.npmjs.com/package/@lacspace/next) | Next.js SDK integration |
90
+
91
+ <div align="center"><sub>Built with care by <a href="https://lacspace.com">Lacspace</a> · Lacspace Free Licence · <a href="https://github.com/lacspace/npm-packages">source</a></sub></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lacspace/env",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Typed, validated environment variables — declare a schema, validate process.env at boot, get a typed frozen object or a clear fail-fast error. A zero-dependency t3-env / envalid alternative.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -38,7 +38,7 @@
38
38
  "typescript"
39
39
  ],
40
40
  "author": "Lacspace <contact@lacspace.com>",
41
- "license": "MIT",
41
+ "license": "SEE LICENSE IN LICENSE",
42
42
  "homepage": "https://lacspace.com/packages",
43
43
  "repository": {
44
44
  "type": "git",