mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 05:05:38 -04:00
Integrate TMDB credits data into the app: cast carousels on title detail pages, person detail pages with biography and filmography, and person search results in the command palette. Includes new persons/titleCast DB tables, profile image caching, and a nightly credits refresh cron job. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
36 lines
976 B
TypeScript
36 lines
976 B
TypeScript
import { headers } from "next/headers";
|
|
import { type NextRequest, NextResponse } from "next/server";
|
|
import { auth } from "@/lib/auth/server";
|
|
import {
|
|
getLocalFilmography,
|
|
getOrFetchPerson,
|
|
getOrFetchPersonByTmdbId,
|
|
} from "@/lib/services/person";
|
|
|
|
const TMDB_PATTERN = /^tmdb-(\d+)$/;
|
|
|
|
export async function GET(
|
|
_req: NextRequest,
|
|
{ params }: { params: Promise<{ id: string }> },
|
|
) {
|
|
const session = await auth.api.getSession({ headers: await headers() });
|
|
if (!session) {
|
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
}
|
|
|
|
const { id } = await params;
|
|
|
|
const tmdbMatch = TMDB_PATTERN.exec(id);
|
|
const person = tmdbMatch
|
|
? await getOrFetchPersonByTmdbId(Number(tmdbMatch[1]))
|
|
: await getOrFetchPerson(id);
|
|
|
|
if (!person) {
|
|
return NextResponse.json({ error: "Person not found" }, { status: 404 });
|
|
}
|
|
|
|
const filmography = getLocalFilmography(person.id);
|
|
|
|
return NextResponse.json({ person, filmography });
|
|
}
|