MCPcopy
hub / github.com/Peppermint-Lab/peppermint / objectStoreRoutes

Function objectStoreRoutes

apps/api/src/controllers/storage.ts:7–42  ·  view source on GitHub ↗
(fastify: FastifyInstance)

Source from the content-addressed store, hash-verified

5const upload = multer({ dest: "uploads/" });
6
7export function objectStoreRoutes(fastify: FastifyInstance) {
8 //
9 fastify.post(
10 "/api/v1/storage/ticket/:id/upload/single",
11 { preHandler: upload.single("file") },
12
13 async (request: FastifyRequest, reply: FastifyReply) => {
14 console.log(request.file);
15 console.log(request.body);
16
17 const uploadedFile = await prisma.ticketFile.create({
18 data: {
19 ticketId: request.params.id,
20 filename: request.file.originalname,
21 path: request.file.path,
22 mime: request.file.mimetype,
23 size: request.file.size,
24 encoding: request.file.encoding,
25 userId: request.body.user,
26 },
27 });
28
29 console.log(uploadedFile);
30
31 reply.send({
32 success: true,
33 });
34 }
35 );
36
37 // Get all ticket attachments
38
39 // Delete an attachment
40
41 // Download an attachment
42}

Callers 1

registerRoutesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected