Files
adam-acs/app/services/references/config_loader.ts
T
Kevin L'Hereec e857b4fbe7 feat: reference providers system with Wassup integration
- Pluggable multi-provider architecture (ReferenceEngine)
- Wassup provider implementation (HTTP GET + X_WASSUP_USER_IP)
- Auto-resolve references on Inform (BOOT/BOOTSTRAP events)
- References displayed in device Identity card
- REST API: GET/POST references per device
- Config via config/references.json
- Fix event extraction for single EventStruct and numeric EventCodes
- Mock Wassup provisioned by home-device-simulator on device creation
2026-06-02 15:52:16 +02:00

26 lines
693 B
TypeScript

import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import type { ReferencesConfig } from './types.js'
const CONFIG_PATH = join(process.cwd(), 'config', 'references.json')
let cachedConfig: ReferencesConfig | null = null
export function loadReferencesConfig(): ReferencesConfig {
if (cachedConfig) return cachedConfig
try {
const raw = readFileSync(CONFIG_PATH, 'utf-8')
cachedConfig = JSON.parse(raw) as ReferencesConfig
return cachedConfig
} catch (_error: any) {
cachedConfig = { providers: [] }
return cachedConfig
}
}
export function reloadReferencesConfig(): ReferencesConfig {
cachedConfig = null
return loadReferencesConfig()
}