fix: validate ID parsing in API routes and player pages for Prisma v7

This commit is contained in:
2026-03-31 00:21:02 -07:00
parent 0f66815ed4
commit a1fb0e25a7
4 changed files with 28 additions and 4 deletions
@@ -11,7 +11,15 @@ export async function POST(
{ params }: { params: { id: string } }
) {
try {
const tournamentId = parseInt(params.id);
const tournamentId = parseInt(params.id, 10);
if (isNaN(tournamentId)) {
return NextResponse.json(
{ error: "Invalid tournament ID" },
{ status: 400 }
);
}
const body = await request.json();
const { games } = body;
@@ -7,7 +7,15 @@ export async function POST(
{ params }: { params: { id: string } }
) {
try {
const tournamentId = parseInt(params.id);
const tournamentId = parseInt(params.id, 10);
if (isNaN(tournamentId)) {
return NextResponse.json(
{ error: "Invalid tournament ID" },
{ status: 400 }
);
}
const body = await request.json();
const { playerIds } = body;
+5 -1
View File
@@ -10,7 +10,11 @@ interface PageProps {
}
export default async function PlayerProfilePage({ params }: PageProps) {
const playerId = parseInt(params.id)
const playerId = parseInt(params.id, 10)
if (isNaN(playerId)) {
notFound()
}
const player = await prisma.player.findUnique({
where: { id: playerId },
+5 -1
View File
@@ -10,7 +10,11 @@ interface PageProps {
}
export default async function PlayerSchedulePage({ params }: PageProps) {
const playerId = parseInt(params.id)
const playerId = parseInt(params.id, 10)
if (isNaN(playerId)) {
notFound()
}
const player = await prisma.player.findUnique({
where: { id: playerId },