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

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