Skip to content

Releases: chintanshah35/envconfig-kit

v0.2.0

26 Jan 05:03

Choose a tag to compare

envconfig-kit v0.2.0 Release Notes

New Validators

Enum Type - Restrict values to a specific set:

NODE_ENV: { 
  type: 'enum', 
  values: ['development', 'staging', 'production'] as const
}

Array Type - Parse comma-separated values (or custom separator):

ALLOWED_HOSTS: { type: 'array' }
TAGS: { type: 'array', separator: '|' }

JSON Type - Parse JSON strings into objects:

FEATURE_FLAGS: { type: 'json' }

Regex Type - Custom pattern validation:

API_VERSION: { type: 'regex', pattern: /^v\d+\.\d+$/ }

Integer Type - Whole numbers only (stricter than number):

PORT: { type: 'integer' }

Secret Masking

Hide sensitive values in error messages:

API_KEY: { type: 'string', secret: true }
// Error messages show API_KEY=**** instead of actual value

Custom Validation

Add your own validation logic:

PORT: { 
  type: 'number',
  validate: (value) => value >= 1024 && value <= 65535
}

Framework Presets

Pre-configured schemas for common patterns:

  • presets.server() - PORT, HOST, NODE_ENV
  • presets.database() - DATABASE_URL, DATABASE_HOST, etc.
  • presets.redis() - REDIS_URL, REDIS_HOST, etc.
  • presets.auth() - AUTH_JWT_SECRET, etc.
  • presets.aws() - AWS_ACCESS_KEY_ID, etc.
  • presets.smtp() - SMTP_HOST, SMTP_PORT, etc.
  • presets.cors() - CORS_ORIGINS, CORS_METHODS, etc.

All presets support custom prefixes:

...presets.database('DB_')  // DB_URL, DB_HOST, etc.

Improvements

  • Improved error messages with actionable fix suggestions
  • Better TypeScript inference for enum types
  • Enhanced test coverage

Breaking Changes

None. All new features are additive and backward compatible.

Installation

npm install envconfig-kit@0.2.0

Full Changelog: v0.1.0...v0.2.0

v0.1.0

14 Jan 00:51

Choose a tag to compare

envconfig-kit v0.1.0

Type-safe environment variables with fail-fast validation. Zero dependencies.

Features

Type Safety

  • Full TypeScript inference for all environment variables
  • Supports string, number, boolean, url, email, port types
  • Optional fields with optional: true
  • Default values for non-required variables

Built-in .env Loading

  • Automatically loads .env, .env.local, .env.development, .env.production
  • Priority order: process.env > .env.local > .env.${NODE_ENV} > .env
  • No need for separate dotenv package

Validation

  • Fail-fast validation on startup
  • Actionable error messages with examples
  • Type conversion (string "3000" → number 3000)
  • URL and email format validation

Transform Support

  • Custom transform functions to parse values
  • Built-in support for CSV splitting, trimming, etc.

CLI Tools

  • npx envconfig-kit init - Initialize configuration
  • npx envconfig-kit check - Validate .env file
  • npx envconfig-kit generate - Generate .env.example
  • npx envconfig-kit doctor - Health check

Export Utilities

  • schemaToMarkdown() - Generate documentation tables
  • schemaToJSON() - Export schema as JSON
  • generateDotenvExample() - Create .env.example files

Installation

npm install envconfig-kit## Quick Start

import { env } from 'envconfig-kit'

const config = env({
PORT: { type: 'number', default: 3000 },
API_KEY: { type: 'string' },
DEBUG: { type: 'boolean', default: false },
DATABASE_URL: { type: 'url' },
})## Bundle Size

  • Zero dependencies
  • ~3KB minified

What's Next?

Check out the README for full documentation and examples.