import { NextRequest, NextResponse } from "next/server"; import { db } from "@/lib/db"; export async function GET(request: NextRequest) { try { const { searchParams } = new URL(request.url); const type = searchParams.get("type"); const platform = searchParams.get("platform"); const limit = parseInt(searchParams.get("limit") || "50"); const where: Record = {}; if (type) where.type = type; if (platform) where.platform = platform; const contents = await db.content.findMany({ where, orderBy: { createdAt: "desc" }, take: limit }); const stats = { total: await db.content.count(), images: await db.content.count({ where: { type: "image" } }), videos: await db.content.count({ where: { type: "video" } }) }; return NextResponse.json({ success: true, contents, stats }); } catch { return NextResponse.json({ success: false, error: "Error" }, { status: 500 }); } } export async function DELETE(request: NextRequest) { try { const { searchParams } = new URL(request.url); const id = searchParams.get("id"); if (!id) return NextResponse.json({ success: false, error: "ID requerido" }, { status: 400 }); await db.censorFlag.deleteMany({ where: { contentId: id } }); await db.content.delete({ where: { id } }); return NextResponse.json({ success: true }); } catch { return NextResponse.json({ success: false, error: "Error" }, { status: 500 }); } }