import type { FastifyReply, FastifyRequest } from 'fastify'; import type { Handler } from '../core/http.js'; import { RequestContextFactory } from './request-context.factory.js'; export abstract class DomainRouteService { protected constructor( protected readonly contextFactory: RequestContextFactory, private readonly handlers: Record, ) {} execute(name: string, request: FastifyRequest, reply: FastifyReply) { const handler = this.handlers[name]; if (!handler) throw new Error(`Missing domain route handler: ${name}`); return handler(this.contextFactory.create(request, reply)); } }