Files
librodrome/server/api/admin/media/[...path].delete.ts
Yvv 9525ed3953
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Bouton PDF par chapitre, badges morceaux améliorés, PDF configurable admin, git sync admin→prod
- Bouton PDF blanc par chapitre avec numéro de page (ChapterHeader)
- Badges morceaux plus visibles (bordure, poids, hover) dans ChapterHeader et SongBadges
- PDF viewer : page cible + panneau signets ouverts par défaut (BookPdfReader)
- Config YAML : pdfFile dans book, chapterPages pour le mapping chapitre→page
- Admin book : section PDF du livre avec chemin éditable et sauvegarde
- Git sync automatique : chaque sauvegarde admin commit+push en prod (ADMIN_GIT_SYNC=true)
- Docker : git installé en prod, volumes pour .git/site/content/public

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 15:32:38 +01:00

33 lines
884 B
TypeScript

import { unlink } from 'node:fs/promises'
import { join } from 'node:path'
export default defineEventHandler(async (event) => {
const path = getRouterParam(event, 'path')
if (!path) {
throw createError({ statusCode: 400, statusMessage: 'No path provided' })
}
// Prevent path traversal
if (path.includes('..')) {
throw createError({ statusCode: 400, statusMessage: 'Invalid path' })
}
const publicDir = join(process.cwd(), 'public')
const filePath = join(publicDir, path)
// Ensure file is within public dir
if (!filePath.startsWith(publicDir)) {
throw createError({ statusCode: 400, statusMessage: 'Invalid path' })
}
try {
await unlink(filePath)
gitSyncContent(`Suppression média ${path}`, [`public/${path}`])
return { ok: true }
}
catch {
throw createError({ statusCode: 404, statusMessage: 'File not found' })
}
})