Skip to content

Class: FileBind

Defined in: packages/config-bound/src/bind/binds/file.ts:91

A Bind that reads configuration values from a JSON, JSONC, or YAML file.

The file is read and parsed once at construction time. Values are cached in memory and served from the cache on every retrieve() call. Call reload to re-read the file when its contents have changed.

Key resolution follows a nested-first strategy: the element path "database.host" first tries data.database.host, then falls back to data["database.host"] for flat-keyed files.

Explicit null values in the file are treated as "not set" and return undefined, allowing the next bind or element default to take over.

Extends

Constructors

Constructor

ts
new FileBind(options): FileBind;

Defined in: packages/config-bound/src/bind/binds/file.ts:97

Parameters

ParameterType
optionsFileBindOptions

Returns

FileBind

Overrides

Bind.constructor

Properties

PropertyModifierTypeInherited fromDefined in
formatreadonlyFileFormat-packages/config-bound/src/bind/binds/file.ts:93
namereadonlyBindNameBind.namepackages/config-bound/src/bind/bind.ts:15
resolvedPathreadonlystring-packages/config-bound/src/bind/binds/file.ts:92

Methods

get()

ts
get<T>(sectionName, elementName): Promise<T | undefined>;

Defined in: packages/config-bound/src/bind/bind.ts:34

Gets the value from the bind for a specific element

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
sectionNamestringThe name of the Section
elementNamestringThe name of the Element

Returns

Promise<T | undefined>

The value of the element

Inherited from

Bind.get


reload()

ts
reload(): void;

Defined in: packages/config-bound/src/bind/binds/file.ts:126

Re-reads and re-parses the configuration file, replacing the cached data.

Returns

void


retrieve()

ts
retrieve<T>(elementPath): Promise<T | undefined>;

Defined in: packages/config-bound/src/bind/binds/file.ts:116

Retrieves a value for the given element path from the cached file data.

Resolution is nested-first (e.g. a.b -> data.a.b) with a fallback to flat keys (e.g. data["a.b"]). null and undefined are treated as unset and return undefined so downstream binds/defaults can take over.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
elementPathstringDot-separated element path to resolve.

Returns

Promise<T | undefined>

The resolved value when present, otherwise undefined.

Overrides

Bind.retrieve