Add Health/Recommendations/Request/Webhook controllers

This commit is contained in:
2026-08-12 21:21:26 +02:00
parent 3c5f723d22
commit e712470013
8 changed files with 313 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
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' });
}
}