loading gradually player sessions instead all at once
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
Reference in New Issue
Block a user