From 2f542c3066ec877f122cc7fbd2175fb296af7386 Mon Sep 17 00:00:00 2001 From: Morten Olsen Date: Mon, 3 Nov 2025 17:10:33 +0100 Subject: [PATCH] simplify post endpoint --- packages/server/src/api/api.documents.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/server/src/api/api.documents.ts b/packages/server/src/api/api.documents.ts index 3e7ffd2..97bf9ec 100644 --- a/packages/server/src/api/api.documents.ts +++ b/packages/server/src/api/api.documents.ts @@ -15,20 +15,15 @@ const documentsPlugin: FastifyPluginAsyncZod = async (app) => { operationId: 'v1.documents.put', tags: ['documents'], summary: 'Upsert documents', - body: z.object({ - items: z.array(upsertDocumentRequestSchema), - }), + body: upsertDocumentRequestSchema, response: { - 200: z.object({ - items: z.array(upsertDocumentResponseSchema), - }), + 200: upsertDocumentResponseSchema, }, }, handler: async (req, reply) => { const documentsService = app.services.get(DocumentsService); - const { items } = req.body; - const results = await Promise.all(items.map((item) => documentsService.upsert(item))); - return reply.send({ items: results }); + const result = await documentsService.upsert(req.body); + return reply.send(result); }, }); };