Download src/app/api/files/route.ts from rais133/omniroute: direct link, hf CLI and curl.
- Browser
- Download file 665 Bytes
-
https://huggingface.co/spaces/rais133/omniroute/resolve/main/src/app/api/files/route.ts
- Command line
-
hf download hf://spaces/rais133/omniroute/src/app/api/files/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/rais133/omniroute/resolve/main/src/app/api/files/route.ts
665 Bytes
| import { NextResponse } from "next/server"; | |
| import { listFiles } from "@/lib/localDb"; | |
| import { requireManagementAuth } from "@/lib/api/requireManagementAuth"; | |
| export async function GET(request: Request) { | |
| const authError = await requireManagementAuth(request); | |
| if (authError) return authError; | |
| try { | |
| const url = new URL(request.url); | |
| const limit = Number.parseInt(url.searchParams.get("limit") || "100", 10); | |
| const files = listFiles({ limit }); | |
| return NextResponse.json({ files }); | |
| } catch (error) { | |
| console.log("Error fetching files:", error); | |
| return NextResponse.json({ error: "Failed to fetch files" }, { status: 500 }); | |
| } | |
| } | |