feat: modernized web application
This commit is contained in:
23
nextjs/src/app/api/players/[key]/route.ts
Normal file
23
nextjs/src/app/api/players/[key]/route.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
import { getPlayersForTournament } from '@/lib/data';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
type RouteContext = {
|
||||
params: Promise<{ key: string }>;
|
||||
};
|
||||
|
||||
export async function GET(_request: Request, context: RouteContext) {
|
||||
try {
|
||||
const { key } = await context.params;
|
||||
const data = await getPlayersForTournament(key);
|
||||
if (data === null) {
|
||||
return NextResponse.json({ error: 'Tournament not found' }, { status: 404 });
|
||||
}
|
||||
return NextResponse.json(data);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return NextResponse.json([], { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user