getSection

View as MarkdownOpen in Claude

Get an entire top-level configuration section with all ${VAR|default} environment-variable references substituted. Internally calls substituteVars() on the resolved value.

Returns an empty object ({}) if the section does not exist or is not an object. For single-value lookups, use get() instead.

Parameters

section
stringRequired

The top-level section name (e.g., "security", "server").

Returns

Record<string, unknown> — the configuration section, with env-var substitution applied; empty object if the section is missing or not an object.

Example

1import { ConfigLoader } from '@signalwire/sdk';
2
3// Given config.json:
4// { "server": { "host": "${HOST|0.0.0.0}", "port": "${PORT|3000}" } }
5
6const loader = new ConfigLoader('config.json');
7
8const serverCfg = loader.getSection('server');
9console.log(serverCfg.host); // "0.0.0.0" (or HOST env var)
10console.log(serverCfg.port); // 3000 (coerced to number)