Next.js full-stack analytics dashboard for new-api. - Direct PostgreSQL readonly queries on logs table - 5 pages: Dashboard, Rankings, Aggregation, Logs, Detail - Dark/Light/System theme with CSS variables - Chinese/English i18n (default Chinese) - Recharts with dual Y-axis for input/output tokens - Lucide icons + Motion animations - Docker + docker-compose with external sinobridge network, port 8019
13 lines
508 B
TypeScript
13 lines
508 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { getTrends } from "@/lib/queries";
|
|
|
|
export async function GET(req: NextRequest) {
|
|
const sp = req.nextUrl.searchParams;
|
|
const granularity = (sp.get("granularity") || "day") as "day" | "week" | "month";
|
|
const startTs = sp.get("start") ? Number(sp.get("start")) : undefined;
|
|
const endTs = sp.get("end") ? Number(sp.get("end")) : undefined;
|
|
|
|
const data = await getTrends(granularity, startTs, endTs);
|
|
return NextResponse.json(data);
|
|
}
|