import { readdir, stat } from "node:fs/promises"; import { resolve } from "node:path"; const filesDir = () => resolve(process.cwd(), "public/files"); export default defineEventHandler(async () => { const dir = filesDir(); try { const names = await readdir(dir); const files = await Promise.all( names.map(async (name) => { const s = await stat(resolve(dir, name)); return { name, size: s.size, modifiedAt: s.mtime.toISOString() }; }), ); return files; } catch { return []; } });