init
This commit is contained in:
31
packages/server/src/endpoints/documents/documents.ts
Normal file
31
packages/server/src/endpoints/documents/documents.ts
Normal 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 };
|
||||
Reference in New Issue
Block a user