import { NextRequest, NextResponse } from "next/server"; import { PrismaClient } from "@prisma/client"; const prisma = new PrismaClient(); export const GET = async (req: NextRequest) => { try { const files = await prisma.file.findMany({ select: { id: true, filename: true, mimetype: true, size: true, createdAt: true, updatedAt: true, }, orderBy: { createdAt: 'desc', }, }); return NextResponse.json({ success: true, files, }); } catch (error) { console.error("Error listing files:", error); return NextResponse.json( { success: false, error: "Failed to list files" }, { status: 500 } ); } finally { await prisma.$disconnect(); } };