import { NextResponse } from "next/server"; import { getServerSession } from "next-auth/next"; import { authOptions } from "@/lib/auth"; import { prisma } from "@/lib/prisma"; export async function GET() { try { const session = await getServerSession(authOptions); if (!session?.user?.id) { return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); } const images = await prisma.userImage.findMany({ where: { userId: session.user.id }, orderBy: { createdAt: "desc" }, }); return NextResponse.json({ images }); } catch (error) { console.error("[IMAGES_GET_ERROR]", error); return NextResponse.json({ error: error.message }, { status: 500 }); } }