Files
sofa/app/api/titles/import/route.ts
T
jakeandClaude Opus 4.6 095b64ab42 Simplify auth, remove abstraction layers, add shadcn components
- Delete lib/api/errors.ts and lib/api/auth-guard.ts, inline
  NextResponse.json() error responses directly in route handlers
- Replace non-standard amber CSS variables with primary/primary-foreground
- Regenerate shadcn UI components with biome-ignore comments
- Add CLAUDE.md for repository guidance
- Update dependencies and pnpm lockfile

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 15:00:15 -05:00

27 lines
789 B
TypeScript

import { headers } from "next/headers";
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth/server";
import { importTitle } from "@/lib/services/metadata";
export async function POST(req: NextRequest) {
const session = await auth.api.getSession({
headers: await headers(),
});
if (!session)
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
const body = await req.json();
const { tmdbId, type } = body;
if (!tmdbId || !type || !["movie", "tv"].includes(type)) {
return NextResponse.json(
{ error: "tmdbId and type (movie|tv) are required" },
{ status: 400 },
);
}
const title = await importTitle(tmdbId, type);
return NextResponse.json(title);
}