initiation librodrome

This commit is contained in:
Yvv
2026-02-20 12:55:10 +01:00
commit 35e2897a73
208 changed files with 18951 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
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)
return { ok: true }
}
catch {
throw createError({ statusCode: 404, statusMessage: 'File not found' })
}
})