mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-07-14 18:15:56 -04:00
- New `lists` service fetches Sonarr/Radarr library via their REST APIs and auto-imports matching titles from TMDB into the user's watchlist - `app/api/lists/[token]/route.ts` webhook endpoint triggers a list sync - Unified `IntegrationCard` component replaces `WebhookCard`, handling both webhook-style (Plex/Jellyfin/Emby) and list-style (Sonarr/Radarr) integrations with per-type config forms - Schema migration adds `sonarr` and `radarr` to the integration type enum and a `listConnections` table for list-based integrations - 212 tests added for the lists service covering import, deduplication, and error handling
27 lines
710 B
TypeScript
27 lines
710 B
TypeScript
import type { NextRequest } from "next/server";
|
|
import { NextResponse } from "next/server";
|
|
import {
|
|
getRadarrList,
|
|
getSonarrList,
|
|
parseStatusParam,
|
|
resolveListToken,
|
|
} from "@/lib/services/lists";
|
|
|
|
export async function GET(
|
|
req: NextRequest,
|
|
{ params }: { params: Promise<{ token: string }> },
|
|
) {
|
|
const { token } = await params;
|
|
const result = resolveListToken(token);
|
|
if (!result) {
|
|
return NextResponse.json([]);
|
|
}
|
|
|
|
const statuses = parseStatusParam(req.nextUrl.searchParams.get("status"));
|
|
|
|
if (result.provider === "sonarr") {
|
|
return NextResponse.json(await getSonarrList(result.userId, statuses));
|
|
}
|
|
return NextResponse.json(getRadarrList(result.userId, statuses));
|
|
}
|