import { NextRequest, NextResponse } from 'next/server' import { getLibrary, removeLibrary } from '@/lib/libraries' import { removeAllAssignmentsForLibrary } from '@/lib/tags' import { requireAdmin } from '@/lib/auth' export async function DELETE( request: NextRequest, { params }: { params: Promise<{ id: string }> } ) { const auth = await requireAdmin(request) if (auth instanceof NextResponse) return auth const { id } = await params const library = getLibrary(id) if (!library) { return NextResponse.json({ error: 'Library not found' }, { status: 404 }) } removeLibrary(id) removeAllAssignmentsForLibrary(id) return new NextResponse(null, { status: 204 }) }