Files
mqtt-ingest/app/src/registry.ts
Nikita Bizyaev e7b44539ae mqtt-ingest draft
2026-06-04 14:40:18 +03:00

19 lines
490 B
TypeScript

import type { TopicHandler } from './types.js'
const handlers = new Map<string, TopicHandler>()
export function register(topic: string, handler: TopicHandler): void {
if (handlers.has(topic)) {
throw new Error(`Handler already registered for topic: ${topic}`)
}
handlers.set(topic, handler)
}
export function getHandler(topic: string): TopicHandler | undefined {
return handlers.get(topic)
}
export function getRegisteredTopics(): string[] {
return [...handlers.keys()]
}