начало чата
All checks were successful
Deploy / deploy (push) Successful in 3m47s

This commit is contained in:
2026-04-16 02:21:54 +06:00
parent 9f39ee6430
commit 0915d3c64d
26 changed files with 1592 additions and 1112 deletions

View File

@@ -0,0 +1,33 @@
import type { FastifyInstance } from 'fastify'
import bcrypt from 'bcrypt'
import { z } from 'zod'
export default function (fastify: FastifyInstance) {
fastify.post('/attachments/upload', async (req, reply) => {
try {
const schema = z.object({
file: z.file(),
})
const input = schema.parse(req.body)
// const file = req.file({ limits: { } })
const id = await bcrypt.hash(input.file, 10)
return {
id,
}
}
catch (err) {
fastify.log.error(err)
reply.code(400)
if (err instanceof z.ZodError) {
reply.send({ error: z.prettifyError(err) })
}
else {
reply.send({ error: err.message })
}
}
})
}