loading gradually player sessions instead all at once

This commit is contained in:
jenz
2026-09-12 13:56:53 +02:00
parent 300000d920
commit 74e72bfdac
4 changed files with 141 additions and 35 deletions
@@ -0,0 +1,15 @@
import { NextRequest, NextResponse } from 'next/server';
import { getSessions } from '@/lib/queries';
const PAGE_SIZE = 10;
export async function GET(req: NextRequest, { params }: { params: Promise<{ steamid: string }> }) {
const { steamid: rawSteamid } = await params;
const steamid = decodeURIComponent(rawSteamid);
const offset = Math.max(0, Number(req.nextUrl.searchParams.get('offset')) || 0);
const sessions = await getSessions(steamid, PAGE_SIZE, offset);
const hasMore = sessions.length === PAGE_SIZE;
return NextResponse.json({ sessions, hasMore });
}