Files
sofa/apps/server/src/orpc/procedures/people.ts
T
jakeandClaude Opus 4.6 d0eca7cf32 feat(core): use TMDB combined credits for full person filmography
The people.detail endpoint now fetches a person's complete filmography
from TMDB's combined_credits API (cast + crew) instead of only returning
locally-enriched titles.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 16:13:43 -04:00

35 lines
1.0 KiB
TypeScript

import { ORPCError } from "@orpc/server";
import {
fetchFullFilmography,
getOrFetchPerson,
getOrFetchPersonByTmdbId,
} from "@sofa/core/person";
import { getUserStatusesByTitleIds } from "@sofa/core/tracking";
import { os } from "../context";
import { authed } from "../middleware";
export const detail = os.people.detail
.use(authed)
.handler(async ({ input, context }) => {
const person = await getOrFetchPerson(input.id);
if (!person)
throw new ORPCError("NOT_FOUND", { message: "Person not found" });
const filmography = await fetchFullFilmography(person.id);
const userStatuses = getUserStatusesByTitleIds(
context.user.id,
filmography.map((c) => c.titleId),
);
return { person, filmography, userStatuses };
});
export const resolve = os.people.resolve
.use(authed)
.handler(async ({ input }) => {
const person = await getOrFetchPersonByTmdbId(input.tmdbId);
if (!person)
throw new ORPCError("NOT_FOUND", { message: "Person not found" });
return { id: person.id };
});