Download src/app/api/usage/chart/route.js from shimen/kirway: direct link, hf CLI and curl.
- Browser
- Download file 699 Bytes
-
https://huggingface.co/spaces/shimen/kirway/resolve/main/src/app/api/usage/chart/route.js
- Command line
-
hf download hf://spaces/shimen/kirway/src/app/api/usage/chart/route.js
-
curl -L -o route.js https://huggingface.co/spaces/shimen/kirway/resolve/main/src/app/api/usage/chart/route.js
699 Bytes
| import { NextResponse } from "next/server"; | |
| import { getChartData } from "@/lib/usageDb"; | |
| const VALID_PERIODS = new Set(["today", "24h", "7d", "30d", "60d", "all"]); | |
| export async function GET(request) { | |
| try { | |
| const { searchParams } = new URL(request.url); | |
| const period = searchParams.get("period") || "7d"; | |
| if (!VALID_PERIODS.has(period)) { | |
| return NextResponse.json({ error: "Invalid period" }, { status: 400 }); | |
| } | |
| const data = await getChartData(period); | |
| return NextResponse.json(data); | |
| } catch (error) { | |
| console.error("[API] Failed to get chart data:", error); | |
| return NextResponse.json({ error: "Failed to fetch chart data" }, { status: 500 }); | |
| } | |
| } | |