release/0.1.0 #18

Merged
ayoub merged 68 commits from release/0.1.0 into main 2026-06-11 18:36:42 +00:00
Showing only changes of commit 9c1413744d - Show all commits

View file

@ -2,7 +2,7 @@
// CRUD des questions manuelles écrites en base (source 'manual').
import { randomUUID } from "node:crypto"
import { writeFile } from "node:fs/promises"
import { mkdir, writeFile } from "node:fs/promises"
import { extname, resolve } from "node:path"
import type { FastifyInstance } from "fastify"
import { desc, eq } from "drizzle-orm"
@ -109,6 +109,8 @@ export async function adminRoutes(app: FastifyInstance) {
const safeExt = IMAGE_EXT.includes(ext) ? ext : ".jpg"
const name = `${randomUUID()}${safeExt}`
const buffer = await file.toBuffer()
// Crée le dossier si besoin (résilient s'il a été supprimé après le démarrage).
await mkdir(resolve(env.uploadsDir), { recursive: true })
await writeFile(resolve(env.uploadsDir, name), buffer)
return { url: `/uploads/${name}` }
})