import { assertFolderAccess, assertLibraryOwner, invalidateCatalogCache, publicLibrary, publicLibraryPage, wipeFolderContents } from '~/server/utils/library' export default defineEventHandler(async (event) => { const { owner } = assertLibraryOwner(event) const id = String(getRouterParam(event, 'id') || '') assertFolderAccess(event, id) const result = await wipeFolderContents(owner, id) // wipeFolderContents already drops the cache. Drop it again so this read // cannot reuse a catalog object captured before the write. invalidateCatalogCache(owner) const library = publicLibrary(event, { light: true }) const page = publicLibraryPage(event, { folderId: id, limit: 50 }) return { ...result, ...library, page, folderId: result.folderId || id } })