node-env-safe
v0.0.1
Published
A lightweight, zero-dependency library for validating environment variables in Node.js
Downloads
105
Maintainers
Readme
node-env-safe
🔐 Type-safe environment variable validation for Node.js
A minimal, zero-dependency utility to validate environment variables with clear errors.
✨ Features
- Type-safe access to environment variables
- Fails fast on missing or invalid values
- Clean and readable error messages
- Zero dependencies
- ESM-first (Node.js 18+)
- Supports strings, numbers, booleans, and arrays
📦 Installation
npm install node-env-safe🚀 Usage
import env from "node-env-safe";
const PORT = env.number("PORT");
const DEBUG = env.boolean("DEBUG");
const APP_NAME = env.string("APP_NAME");📦 Array Usage
ALLOWED_IDS=["a","b","c"]import env from "node-env-safe";
const ALLOWED_IDS = env.array("ALLOWED_IDS", "string");Supported array types:
- string
- number
- boolean
🛠 API
env.string(key)
env.number(key)
env.boolean(key)
env.array(key, type)📄 License
ISC © Faizkhan
