Files
vfxreview/app/api/storyboard/shots/route.ts
T
twotalesanimation 77a3161f0c
Deploy / deploy (push) Successful in 2m53s
Storyboard Feature
2026-07-22 12:19:19 +02:00

45 lines
1.2 KiB
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/auth";
import { db } from "@/lib/db";
// GET /api/storyboard/shots?projectId=xxx
export async function GET(req: NextRequest) {
const session = await auth();
if (!session?.user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
if (!["ADMIN", "PRODUCER", "SUPERVISOR"].includes(session.user.role)) {
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
}
const projectId = req.nextUrl.searchParams.get("projectId");
if (!projectId) return NextResponse.json({ error: "projectId required" }, { status: 400 });
const shots = await db.shot.findMany({
where: { projectId },
select: {
id: true,
shotCode: true,
scene: true,
episode: true,
shotNumber: true,
sequence: true,
description: true,
notes: true,
status: true,
thumbnailUrl: true,
frameStart: true,
frameEnd: true,
fps: true,
isKeyShot: true,
shotVersion: true,
shotGroup: { select: { id: true, name: true } },
},
orderBy: [
{ episode: "asc" },
{ scene: "asc" },
{ shotNumber: "asc" },
],
});
return NextResponse.json({ shots });
}