Files
sofa/app/api/person/[id]/route.ts
T
jake 73b07f5ff6 Refactor auth session handling and server actions across app
- Overhaul `lib/auth/server.ts` and `lib/auth/session.ts`; update all API
  routes and server actions to use the revised session pattern
- Refactor server actions (settings, titles, watchlist, setup) for
  consistency with new auth layer
- Extract `SetupForm` into its own client component with `useActionState`,
  animated steps, and copyable env snippets
- Move landing page redirect logic into `app/page.tsx`; slim down
  `LandingPage` component
- Add `proxy.ts` for local dev proxying
- Minor cleanup to `NavBar`, `MobileTabBar`, and `TitleCard`
2026-03-06 17:05:49 -05:00

35 lines
906 B
TypeScript

import { type NextRequest, NextResponse } from "next/server";
import { getSession } from "@/lib/auth/session";
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 getSession();
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 });
}