@orveth/config
v0.2.0
Published
Typed configuration parsing from environment and custom sources.
Maintainers
Readme
@orveth/config
Package name
@orveth/config
Purpose
Provides a small, strict configuration parsing toolkit backed by an explicit ConfigSource (typically environment variables).
Installation
pnpm add @orveth/config @orveth/errors@orveth/config depends on @orveth/errors at runtime (parsers throw ConfigError).
Basic usage
import {
coercedInteger,
createMapSource,
createProcessEnvSource,
parseConfig,
requiredString,
} from "@orveth/config";
const source = createProcessEnvSource();
const config = parseConfig(source, {
port: { key: "PORT", parse: coercedInteger("PORT", { defaultValue: 3000 }) },
name: { key: "APP_NAME", parse: requiredString("APP_NAME") },
});API overview
Exports include:
ConfigSourceinterface and factories:createProcessEnvSource,createMapSource- Parsers:
requiredString,optionalString,coercedInteger,coercedBoolean parseConfig(source, shape)and supporting types:ConfigParser,ConfigField,ConfigShape
Design notes
- Parsing is strict: invalid input throws
ConfigErrorrather than returning partial objects. createMapSourceexists primarily for tests and for non-process.envconfiguration providers.
Error behavior
Parsers throw ConfigError (@orveth/errors) with stable code values and optional details such as { raw: string }.
TypeScript notes
This package uses Node’s process.env typing (@types/node in development). It ships .d.ts declarations.
License
Released under the MIT License. See the repository LICENSE file.
