Files

14 lines
551 B
TypeScript
Raw Permalink Normal View History

import { NextResponse } from "next/server";
import { getSessionTimeline } from "@/lib/db/queries/stats";
import { withRouteLogging } from "@/lib/api/with-route-logging";
export const GET = withRouteLogging(
"stats.session-timeline",
async (req: Request, { params }: { params: Promise<{ id: string }> }) => {
const { id } = await params;
const bucketMs = Number(new URL(req.url).searchParams.get("bucketMs") ?? 1000);
const timeline = await getSessionTimeline(Number(id), bucketMs);
return NextResponse.json({ timeline });
},
);