Spaces:
Paused
Paused
Download src/app/api/cache/stats/route.ts from igorkurgin/omniroute: direct link, hf CLI and curl.
- Browser
- Download file 988 Bytes
-
https://huggingface.co/spaces/igorkurgin/omniroute/resolve/main/src/app/api/cache/stats/route.ts
- Command line
-
hf download hf://spaces/igorkurgin/omniroute/src/app/api/cache/stats/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/igorkurgin/omniroute/resolve/main/src/app/api/cache/stats/route.ts
988 Bytes
| import { NextRequest, NextResponse } from "next/server"; | |
| import { getPromptCache } from "@/lib/cacheLayer"; | |
| import { isAuthenticated } from "@/shared/utils/apiAuth"; | |
| export async function GET(req: NextRequest) { | |
| if (!(await isAuthenticated(req))) { | |
| return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); | |
| } | |
| try { | |
| const cache = getPromptCache(); | |
| const stats = (cache as any).getStats(); | |
| return NextResponse.json(stats); | |
| } catch (error) { | |
| return NextResponse.json({ error: (error as any).message }, { status: 500 }); | |
| } | |
| } | |
| export async function DELETE(req: NextRequest) { | |
| if (!(await isAuthenticated(req))) { | |
| return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); | |
| } | |
| try { | |
| const cache = getPromptCache(); | |
| (cache as any).clear(); | |
| return NextResponse.json({ success: true, message: "Cache cleared" }); | |
| } catch (error) { | |
| return NextResponse.json({ error: (error as any).message }, { status: 500 }); | |
| } | |
| } | |