get

View as MarkdownOpen in Claude

Retrieve a configuration value using a dot-notation path (e.g., 'server.port'). Prototype-pollution keys (__proto__, constructor, prototype) are blocked and return the default value.

Parameters

path
stringRequired

Dot-separated key path into the config object (e.g., "server.port", "security.ssl_enabled").

defaultValue
T

Value returned when the path does not exist.

Returns

T — The resolved value, or defaultValue if not found.

Example

1import { ConfigLoader } from '@signalwire/sdk';
2
3const config = new ConfigLoader('./config.json');
4
5const port = config.get<number>('server.port', 3000);
6const ssl = config.get<boolean>('security.ssl_enabled', false);
7const user = config.get<string>('security.auth.basic.user', 'signalwire');
8
9console.log(`Port: ${port}, SSL: ${ssl}, User: ${user}`);