48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { prisma } from "@/lib/db";
|
|
import { requireAuth } from "@/lib/session";
|
|
|
|
export async function GET(
|
|
_req: NextRequest,
|
|
{ params }: { params: Promise<{ id: string }> },
|
|
) {
|
|
const { error, user } = await requireAuth();
|
|
if (error || !user) return error!;
|
|
|
|
const { id } = await params;
|
|
|
|
const job = await prisma.job.findFirst({
|
|
where: { id, userId: user.id },
|
|
include: {
|
|
items: {
|
|
orderBy: { audioFilename: "asc" },
|
|
select: {
|
|
id: true,
|
|
audioFilename: true,
|
|
title: true,
|
|
description: true,
|
|
tags: true,
|
|
privacy: true,
|
|
categoryId: true,
|
|
resolution: true,
|
|
status: true,
|
|
youtubeVideoId: true,
|
|
error: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
if (!job) {
|
|
return NextResponse.json({ error: "Job not found" }, { status: 404 });
|
|
}
|
|
|
|
return NextResponse.json({
|
|
id: job.id,
|
|
status: job.status,
|
|
createdAt: job.createdAt.toISOString(),
|
|
completedAt: job.completedAt?.toISOString() ?? null,
|
|
items: job.items,
|
|
});
|
|
}
|