mirror of
https://github.com/FJurmanovic/sugarr.git
synced 2026-11-11 07:41:08 +00:00
26 lines
864 B
TypeScript
26 lines
864 B
TypeScript
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' });
|
|
}
|
|
}
|