@chabdulwahab/env-ok
v1.0.4
Published
Zero-dependency, high-performance environment variable guard.
Downloads
32
Maintainers
Readme
@chabdulwahab/env-ok
A zero-dependency, ultra-lightweight environment variable validator for Node.js and TypeScript. It automatically ensures environment variables defined in .env.example are present in either your local .env file or process.env before your application starts.
Features
- Zero third-party dependencies (uses only native Node.js APIs)
- Under 2KB compiled production bundle
- TypeScript support with generated declaration files out of the box
- Works in Docker, CI, and serverless environments (reads from both physical files and process.env)
- Clean, minimal, high-contrast console error reports on failure
Installation
npm install @chabdulwahab/env-okUsage
Import the package at the top of your application entry point:
import '@chabdulwahab/env-ok';
// Application code starts hereBehavior
- Resolves
.env.examplein the project root. If the file is not found, the guard exits silently. - Extracts required environment keys from
.env.example. - Verifies that every key is defined in either the local
.envfile orprocess.env. - If keys are missing, prints a clean ASCII error block to stderr and terminates the process with code 1.
- If all required keys are resolved, the application proceeds with zero performance impact.
Author
Created by Ch Abdul Wahhab.
License
MIT
