xPulse
πŸ‡¬πŸ‡§ EN
Pages
Contents

API

config.load(options?)

Loads .env and xpulse.json, merges defaults and resolves ${VAR}. Emits config:loaded after successful load.

await config.load();
await config.load({ path: '/app', env: 'stage' });
Option Type Description
path string Directory containing xpulse.json – default: process.cwd()
env string Environment for .env.{env} – fallback: process.env.NODE_ENV

Errors:

Situation Behaviour
xpulse.json not found throws Error
Invalid JSON throws Error
name missing throws Error
Unknown keys ignored, no warning
${VAR} unresolvable warning, value stays ${VAR}

config.get(path, fallback?)

Returns a value from the configuration. Supports dot notation.

config.get('http.port') // '3000'
config.get('i18n.locales') // ['de', 'en']
config.get('sources.chat.url') // 'https://chat.xpulse.one'
config.get('release.current') // '1.3.0' (custom key)
config.get('missing.key', 'default') // 'default'
config.get('missing.key') // null
Parameter Type Description
path string Dot-notation path
fallback unknown Returned if path does not exist (default: null)

config.all()

Returns all configuration values – including defaults and resolved ${VAR}. Returns a copy, not a reference.

const all = config.all();
// β†’ { name: 'xpulse-web', type: 'tool', http: { port: '3000' }, ... }

config.name

Shorthand for config.get('name').

config.name // 'xpulse-web'

config.type

Shorthand for config.get('type').

config.type // 'tool'

config.loaded

true after a successful load().

config.loaded // true | false

Event: `config:loaded`

Emitted after load().

// Payload:
{
name: 'xpulse-web',
type: 'tool',
env: 'production', // process.env.NODE_ENV | null
files: [
'/app/xpulse.json',
'/app/.env',
'/app/.env.production', // only if present
]
}
en/api.md 2026-03-13