xPulse
🇩🇪 DE

API

config.load(options?)

Lädt .env und xpulse.json, merged Fallbacks und löst ${VAR} auf. Feuert config:loaded nach erfolgreichem Laden.

await config.load();
await config.load({ path: '/app', env: 'stage' });
Option Typ Beschreibung
path string Verzeichnis mit xpulse.json – Standard: process.cwd()
env string Environment für .env.{env} – Fallback: process.env.NODE_ENV

Fehler:

Situation Verhalten
xpulse.json nicht gefunden wirft Error
Ungültiges JSON wirft Error
name fehlt wirft Error
Unbekannte Keys ignoriert, keine Warnung
${VAR} nicht auflösbar Warnung, Wert bleibt ${VAR}

config.get(path, fallback?)

Gibt einen Wert aus der Konfiguration zurück. Unterstützt 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 Typ Beschreibung
path string Dot-Notation Pfad
fallback unknown Rückgabe wenn Pfad nicht existiert (Standard: null)

config.all()

Gibt alle Konfigurationswerte zurück – inkl. Fallbacks und aufgelösten ${VAR}. Gibt eine Kopie zurück, keine Referenz.

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

config.name

Kurzform für config.get('name').

config.name // 'xpulse-web'

config.type

Kurzform für config.get('type').

config.type // 'tool'

config.loaded

true nach erfolgreichem load().

config.loaded // true | false

Event: `config:loaded`

Wird nach load() emittiert.

// Payload:
{
name: 'xpulse-web',
type: 'tool',
env: 'production', // process.env.NODE_ENV | null
files: [
'/app/xpulse.json',
'/app/.env',
'/app/.env.production', // nur wenn vorhanden
]
}
de/api.md 2026-03-13