interface IConfig
Since 0.1.0

Type-safe configuration access. Values originate from environment variables and .env files, validated at startup.

Examples

Example 1

const config = ctx.services.get<IConfig>(CAPABILITIES.CONFIG);
const port = config.get<number>('PORT', { default: 3000 });
const dbUrl = config.getOrThrow<string>('DATABASE_URL');

Methods

get<T>(key: string): T | undefined

Reads a configuration value.

get<T>(
key: string,
options: { readonly default: T; }
): T

Reads a configuration value with a fallback.

getOrThrow<T>(key: string): T

Reads a required configuration value.

has(key: string): boolean

Reports whether a key is present.

Usage

import { type IConfig } from "common/src/index.ts";