From a18536dd5f8070428e8d9e744aaefa7b2eca9ecb Mon Sep 17 00:00:00 2001 From: codex-bot Date: Wed, 22 Oct 2025 09:46:50 -0300 Subject: [PATCH] =?UTF-8?q?fix(api):=20Next.js=2016=20route=20handler=20ty?= =?UTF-8?q?pes=20=E2=80=94=20params=20is=20Promise=20in=20context?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update GET signature to (req: NextRequest, ctx: { params: Promise<{id:string}> }) - Await ctx.params and pass id to Convex client - Keeps NextResponse return type --- src/app/api/admin/machines/[id]/details/route.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/api/admin/machines/[id]/details/route.ts b/src/app/api/admin/machines/[id]/details/route.ts index 8271870..ccf5f46 100644 --- a/src/app/api/admin/machines/[id]/details/route.ts +++ b/src/app/api/admin/machines/[id]/details/route.ts @@ -1,15 +1,16 @@ -import { NextResponse } from "next/server" +import { NextRequest, NextResponse } from "next/server" import type { Id } from "@/convex/_generated/dataModel" import { api } from "@/convex/_generated/api" import { createConvexClient, ConvexConfigurationError } from "@/server/convex-client" export const dynamic = "force-dynamic" -export async function GET(_req: Request, { params }: { params: { id: string } }) { +export async function GET(_req: NextRequest, ctx: { params: Promise<{ id: string }> }) { try { const client = createConvexClient() - const id = params.id as Id<"machines"> - const data = (await client.query(api.machines.getById, { id, includeMetadata: true })) as unknown + const { id } = await ctx.params + const machineId = id as Id<"machines"> + const data = (await client.query(api.machines.getById, { id: machineId, includeMetadata: true })) as unknown if (!data) return NextResponse.json({ error: "Not found" }, { status: 404 }) return NextResponse.json(data, { status: 200 }) } catch (err) { @@ -20,4 +21,3 @@ export async function GET(_req: Request, { params }: { params: { id: string } }) return NextResponse.json({ error: "Internal error" }, { status: 500 }) } } -