Download src/app/api/images/route.js from NeoPy/hugging-c-ai: direct link, hf CLI and curl.
- Browser
- Download file 716 Bytes
-
https://huggingface.co/NeoPy/hugging-c-ai/resolve/main/src/app/api/images/route.js
- Command line
-
hf download hf://NeoPy/hugging-c-ai/src/app/api/images/route.js
-
curl -L -o route.js https://huggingface.co/NeoPy/hugging-c-ai/resolve/main/src/app/api/images/route.js
716 Bytes
| 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 }); | |
| } | |
| } | |