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
new FileBind(options): FileBind;Defined in: packages/config-bound/src/bind/binds/file.ts:97
Parameters
| Parameter | Type |
|---|---|
options | FileBindOptions |
Returns
FileBind
Overrides
Properties
| Property | Modifier | Type | Inherited from | Defined in |
|---|---|---|---|---|
format | readonly | FileFormat | - | packages/config-bound/src/bind/binds/file.ts:93 |
name | readonly | BindName | Bind.name | packages/config-bound/src/bind/bind.ts:15 |
resolvedPath | readonly | string | - | packages/config-bound/src/bind/binds/file.ts:92 |
Methods
get()
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
| Parameter | Type | Description |
|---|---|---|
sectionName | string | The name of the Section |
elementName | string | The name of the Element |
Returns
Promise<T | undefined>
The value of the element
Inherited from
reload()
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()
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
| Parameter | Type | Description |
|---|---|---|
elementPath | string | Dot-separated element path to resolve. |
Returns
Promise<T | undefined>
The resolved value when present, otherwise undefined.