Download src/app/api/commitments/route.ts from luguog/over: direct link, hf CLI and curl.
- Browser
- Download file 827 Bytes
-
https://huggingface.co/spaces/luguog/over/resolve/main/src/app/api/commitments/route.ts
- Command line
-
hf download hf://spaces/luguog/over/src/app/api/commitments/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/luguog/over/resolve/main/src/app/api/commitments/route.ts
827 Bytes
| import { NextRequest, NextResponse } from "next/server"; | |
| import { listCommitments, loadMetrics } from "@/lib/commitment/store"; | |
| export const dynamic = "force-dynamic"; | |
| export const maxDuration = 30; | |
| export async function GET(request: NextRequest) { | |
| try { | |
| const commitments = listCommitments(); | |
| const metrics = loadMetrics(); | |
| const limitRaw = request.nextUrl.searchParams.get("limit"); | |
| const limit = limitRaw ? Math.max(1, Math.min(500, parseInt(limitRaw))) : 200; | |
| return NextResponse.json({ | |
| success: true, | |
| count: commitments.length, | |
| commitments: commitments.slice(0, limit), | |
| metrics, | |
| timestamp: new Date().toISOString(), | |
| }); | |
| } catch (e: any) { | |
| console.error("[commitments] error:", e); | |
| return NextResponse.json({ error: e.message }, { status: 500 }); | |
| } | |
| } | |