Skip to main content
zerotal

Documentation


Documentation / zerotal / config-reexport / ConfigLoader

Class: ConfigLoader

Defined in: packages/core/src/config/ConfigLoader.ts:20

A loaded set of config files, keyed by filename (config/app.tsapp). Pass all() (or the loader itself) to Application.create({ config }) / app.useConfig(...).

Constructors

Constructor

new ConfigLoader(_map, _validators?): ConfigLoader

Defined in: packages/core/src/config/ConfigLoader.ts:21

Parameters

_map

ConfigMap

_validators?

readonly object[] = []

Returns

ConfigLoader

Methods

all()

all(): ConfigMap

Defined in: packages/core/src/config/ConfigLoader.ts:27

The full namespace → config map.

Returns

ConfigMap


get()

get<T>(key, fallback?): T

Defined in: packages/core/src/config/ConfigLoader.ts:38

Dot-path read, e.g. get("database.url").

Type Parameters

T

T = unknown

Parameters

key

string

Dot-notation path across the loaded namespaces.

fallback?

T

Value returned when the path is missing.

Returns

T

The stored value, or fallback when unset.


has()

has(key): boolean

Defined in: packages/core/src/config/ConfigLoader.ts:51

Whether a value exists at the given dot-path.

Parameters

key

string

Returns

boolean


validate()

validate(): this

Defined in: packages/core/src/config/ConfigLoader.ts:63

Run each config file's optional validate(config) named export against its value, throwing on the first failure. Returns this for chaining. (Config files that read env at module load are already validated by the act of loading.)

Returns

this

this, so the call chains into Application.create({ config }).

Throws

Whatever a config file's validate(config) export throws on the first failure.