This commit is contained in:
Morten Olsen
2025-12-09 20:32:08 +01:00
commit 2cfd54c344
54 changed files with 8794 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import type { FastifyPluginAsyncZod } from 'fastify-type-provider-zod';
import {
DocumentsService,
documentUpsertResultSchema,
documentUpsertSchema,
} from '#root/services/documents/documents.ts';
const documentEndpoints: FastifyPluginAsyncZod = async (instance) => {
instance.route({
method: 'POST',
url: '',
schema: {
operationId: 'POST/documents',
tags: ['documents'],
summary: 'Upsert document',
body: documentUpsertSchema,
response: {
200: documentUpsertResultSchema,
},
},
handler: async (req, reply) => {
const { services } = instance;
const documentsService = services.get(DocumentsService);
const response = await documentsService.upsert(req.body);
await reply.send(response);
},
});
};
export { documentEndpoints };