Spaces:
Sleeping
Sleeping
Download src/app/api/generation/[id]/route.ts from veltrixcode/Iot: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/veltrixcode/Iot/resolve/main/src/app/api/generation/%5Bid%5D/route.ts
- Command line
-
hf download 'hf://spaces/veltrixcode/Iot/src/app/api/generation/[id]/route.ts'
-
curl -L -o route.ts https://huggingface.co/spaces/veltrixcode/Iot/resolve/main/src/app/api/generation/%5Bid%5D/route.ts
1.06 kB
| import { auth } from "@/auth" | |
| import { prisma } from "@/lib/prisma" | |
| import { NextResponse } from "next/server" | |
| export async function DELETE( | |
| req: Request, | |
| { params }: { params: Promise<{ id: string }> } | |
| ) { | |
| try { | |
| const session = await auth() | |
| if (!session?.user?.id) { | |
| return new NextResponse("Unauthorized", { status: 401 }) | |
| } | |
| const { id } = await params | |
| // Verify ownership | |
| const generation = await prisma.generation.findUnique({ | |
| where: { id }, | |
| }) | |
| if (!generation) { | |
| return new NextResponse("Not Found", { status: 404 }) | |
| } | |
| if (generation.userId !== session.user.id) { | |
| return new NextResponse("Forbidden", { status: 403 }) | |
| } | |
| await prisma.generation.delete({ | |
| where: { id }, | |
| }) | |
| return new NextResponse(null, { status: 204 }) | |
| } catch (error) { | |
| console.error("[GENERATION_DELETE]", error) | |
| return new NextResponse("Internal Error", { status: 500 }) | |
| } | |
| } | |