Releases: sujwn/envus
Releases · sujwn/envus
v2.0.0
envus v2.0.0 – Complete Rewrite
envus v2 introduces a fully redesigned environment configuration system built for modern Node.js applications. This version replaces the legacy API with a more expressive, type-safe, and extensible schema-based approach.
Highlights
- New schema builder
Define environment variables explicitly using schema("KEY"), with support for number, boolean, enum, array, JSON, and custom types. defineConfig()
Build fully validated, nested configuration objects with strong TypeScript inference.loadEnv()
Lightweight optional .env loader (zero dependencies).- Strict mode
Detect unexpected environment variables for safer deployments. - Clear validation errors
Aggregated and structured error reporting. - Zero dependencies
Minimal footprint and fast startup.
Breaking Changes
- Removed legacy functions:
- validateEnv()
- resolveEnv()
- The previous v1 configuration format using $env, type, and default is no longer supported.
If you need the old API, install:
npm install envus@1.0.0-aMigration
- Replace
$envmappings withschema("KEY"). - Replace the recursive config object resolution with
defineConfig(). - Use
.default(),.required(),.min(),.max(),.pattern(), etc. for validation.
A simple migration example:
Before (v1)
{
db: {
url: { $env: "DB_URL", type: "string" },
port: { $env: "DB_PORT", default: 3306 }
}
}After (v2)
defineConfig({
db: {
url: schema("DB_URL").string().required(),
port: schema("DB_PORT").number().default(3306),
}
});A full README is available here
v1.0.0
envus v1.0.0 - Initial release
A simple utility to validate and resolve environment variables with type safety and defaults.
- validateEnv()
- resolveEnv()
Usage
const { validateEnv, resolveEnv } = require('envus');
const config = {
db: {
host: { $env: 'DB_HOST', default: 'localhost', type: 'string' },
port: { $env: 'DB_PORT', default: 5432, type: 'number' },
ssl: { $env: 'DB_SSL', default: false, type: 'boolean' },
options: { $env: 'DB_OPTIONS', type: 'json', default: {} },
},
};
// Step 1: Validate environment variables
validateEnv(config);
// Step 2: Resolve config with values from process.env or defaults
const resolved = resolveEnv(config);
console.log(resolved);
/*
{
db: {
host: "localhost",
port: 5432,
ssl: false,
options: {}
}
}
*/