import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'; import { Controller } from '../../core/server/Controller'; import type { PromptService } from '../../core/langfuse/PromptService'; interface InvalidateBody { promptName?: string; } export class WebhookController extends Controller { constructor(private readonly promptService: PromptService) { super(); } register(app: FastifyInstance): void { app.post('/webhooks/langfuse/invalidate', (request, reply) => this.handle(request as FastifyRequest<{ Body: InvalidateBody }>, reply) ); } private async handle(request: FastifyRequest<{ Body: InvalidateBody }>, reply: FastifyReply) { const promptName = request.body?.promptName; this.promptService.invalidate(promptName); reply.send({ invalidated: true, promptName: promptName ?? 'all' }); } }