// Reports which backend each scalable subsystem is using, for the health // endpoint and startup logging. import { isRedisEnabled, isRedisHealthy, getRedisHealthDetail } from './redis.js'; import { getRateLimiter } from './stores/rateLimiter.js'; import { getPubSub } from './stores/pubsub.js'; import { getCache } from './stores/cache.js'; import { getLock } from './stores/lock.js'; import { getLoginLockout } from './stores/loginLockout.js'; import { getStorage } from './storage.js'; export function describeBackends() { return { cache: getCache().backend, rateLimiter: getRateLimiter().backend, pubsub: getPubSub().backend, lock: getLock().backend, loginLockout: getLoginLockout().backend, storage: getStorage().backend, }; } export function describeRedis() { return { enabled: isRedisEnabled(), healthy: isRedisHealthy(), ...getRedisHealthDetail() }; } /** Log one line per subsystem at startup so the active backend is obvious. */ export function logSelectedBackends(): void { const b = describeBackends(); const r = describeRedis(); console.log('[startup] Subsystem backends:'); console.log(` redis: ${r.enabled ? 'enabled' : 'disabled (in-memory fallback)'}`); console.log(` cache: ${b.cache}`); console.log(` rate limiter: ${b.rateLimiter}`); console.log(` pub/sub: ${b.pubsub}`); console.log(` lock: ${b.lock}`); console.log(` login lockout:${b.loginLockout}`); console.log(` storage: ${b.storage}`); }