ConfigLoader

View as MarkdownOpen in Claude

ConfigLoader loads JSON configuration files and substitutes environment variables using ${VAR|default} syntax. It provides dot-notation access for nested values and supports method chaining.

1import { ConfigLoader } from '@signalwire/sdk';
2
3const config = new ConfigLoader('./config.json');
4const port = config.get<number>('server.port', 3000);

Constructor

filePaths
string | string[]

Path(s) to a JSON config file to load on construction. A single string is loaded directly; an array is searched in order and the first existing file is loaded (mirroring the Python SDK’s ordered-search behaviour). If no file in the array exists, the paths are recorded but no error is thrown. If omitted, use load() or loadFromObject() later.

Properties

configPaths
string[]

The ordered list of config file paths passed to the constructor or searched during loading. Returns a defensive copy.

Methods

Example

1import { ConfigLoader } from '@signalwire/sdk';
2
3// Load from a specific file
4const config = new ConfigLoader('./config.json');
5console.log('File:', config.getFilePath());
6
7const port = config.get<number>('server.port', 3000);
8const host = config.get<string>('server.host', '0.0.0.0');
9console.log(`Listening on ${host}:${port}`);