What's Changed
New Contributors
✨ Added
createConfig — Typed computed configuration values
- Introduced
createConfig, a new helper that builds on parseEnv to support computed (derived) configuration values.
- Computed values:
- Are calculated after schema validation
- Receive the fully parsed and typed config (not raw strings)
- Support flat and deeply nested structures
- Are deep-merged with the parsed schema output
- Full TypeScript type inference for:
- Parsed environment variables
- Computed values (including nested and mixed structures)
- Computed functions are skipped if schema validation fails, ensuring safety and correctness.
const config = createConfig(process.env, {
schema: {
db: {
host: envvar('DB_HOST', z.string()),
port: envvar('DB_PORT', z.coerce.number()),
},
},
computed: {
dbUrl: (raw) => `${raw.db.host}:${raw.db.port}`,
},
});
**Full Changelog**: https://github.com/CatchMe2/envase/compare/v1.2.2...v1.3.0