Releases: chintanshah35/envconfig-kit
v0.2.0
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 valueCustom 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_ENVpresets.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.0Full Changelog: v0.1.0...v0.2.0
v0.1.0
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,porttypes - 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
dotenvpackage
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 configurationnpx envconfig-kit check- Validate .env filenpx envconfig-kit generate- Generate .env.examplenpx envconfig-kit doctor- Health check
Export Utilities
schemaToMarkdown()- Generate documentation tablesschemaToJSON()- Export schema as JSONgenerateDotenvExample()- 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.