fix: validate ID parsing in API routes and player pages for Prisma v7
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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 },
|
||||
|
||||
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user