typed-environment-loader
Version:
typed-environment-loader is a lightweight utility for loading environment variables in a typed manner, ensuring type safety and consistency in your Node.js applications.
22 lines (21 loc) • 938 B
TypeScript
import { ParserContext, ParserResult, SchemaItem } from '../types';
export interface TypedParserContext<Type extends SchemaItem> extends ParserContext {
schema: Type;
}
export interface TypedParserResult<Type> extends ParserResult {
value: Type;
}
export interface TypedParser<Type extends SchemaItem, Registry> {
parse(context: TypedParserContext<Type>): TypedParserResult<Registry>;
}
type ParserConstructor<Type extends SchemaItem = SchemaItem, Registry = unknown> = new (registry: ParserRegistry) => TypedParser<Type, Registry>;
export declare class ParserRegistry {
private readonly _parsers;
private readonly _debug;
constructor();
get parsers(): ReadonlyMap<string, ParserConstructor>;
register<T extends SchemaItem, R>(type: string, parserClass: ParserConstructor<T, R>): this;
parse<T = unknown>(context: ParserContext): TypedParserResult<T>;
private _registerDefaultParsers;
}
export {};