Download src/app/api/feynman/verify/route.ts from NAP1320/RotNot: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/spaces/NAP1320/RotNot/resolve/main/src/app/api/feynman/verify/route.ts
- Command line
-
hf download hf://spaces/NAP1320/RotNot/src/app/api/feynman/verify/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/NAP1320/RotNot/resolve/main/src/app/api/feynman/verify/route.ts
1.31 kB
| import { NextRequest, NextResponse } from "next/server"; | |
| import { runVerification, getSourceHealthSummary } from "@/lib/sources/verify"; | |
| import { withApiError } from "@/lib/api-error"; | |
| /** | |
| * POST /api/feynman/verify | |
| * | |
| * Run source verification — checks stale/unverified source URLs, | |
| * removes dead sources, and invalidates teaching caches that fall | |
| * below the minimum source threshold. | |
| * | |
| * Body (optional): { limit?: number } — max sources to check (default 50) | |
| * | |
| * Returns verification results and updated health summary. | |
| */ | |
| export const POST = withApiError(async (request: NextRequest) => { | |
| let limit: number | undefined; | |
| try { | |
| const body = await request.json(); | |
| if (body.limit && typeof body.limit === "number" && body.limit > 0) { | |
| limit = Math.min(body.limit, 200); // cap at 200 per run | |
| } | |
| } catch { | |
| // Empty body is fine — use defaults | |
| } | |
| const result = await runVerification(limit); | |
| const health = await getSourceHealthSummary(); | |
| return NextResponse.json({ | |
| verification: result, | |
| health, | |
| }); | |
| }); | |
| /** | |
| * GET /api/feynman/verify | |
| * | |
| * Returns source health summary without running verification. | |
| */ | |
| export const GET = withApiError(async () => { | |
| const health = await getSourceHealthSummary(); | |
| return NextResponse.json({ health }); | |
| }); | |