mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 14:25:02 +00:00
Fix Next.js 15 route handler param signatures
Next.js 15 made params a Promise that needs to be awaited. Fixed route handlers: - /api/github/actions/runs/[runId]/logs/route.ts - /api/packages/data/[packageId]/handlers/get-package-data.ts - /api/packages/data/[packageId]/handlers/put-package-data.ts - /api/packages/data/[packageId]/handlers/delete-package-data.ts All handlers now properly await params before access. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,15 +8,13 @@ import { resolveGitHubRepo } from '@/lib/github/resolve-github-repo'
|
||||
import { getSessionUser, STATUS } from '@/lib/routing'
|
||||
import { getRoleLevel } from '@/lib/constants'
|
||||
|
||||
interface RouteParams {
|
||||
params: {
|
||||
runId: string
|
||||
}
|
||||
}
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
export const GET = async (request: NextRequest, { params }: RouteParams) => {
|
||||
export const GET = async (
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ runId: string }> }
|
||||
) => {
|
||||
const resolvedParams = await params
|
||||
// Require authentication - logs may contain sensitive info
|
||||
const session = await getSessionUser(request)
|
||||
|
||||
@@ -36,7 +34,7 @@ export const GET = async (request: NextRequest, { params }: RouteParams) => {
|
||||
)
|
||||
}
|
||||
|
||||
const runId = Number(params.runId)
|
||||
const runId = Number(resolvedParams.runId)
|
||||
if (!Number.isFinite(runId) || runId <= 0) {
|
||||
return NextResponse.json({ error: 'Invalid run id' }, { status: 400 })
|
||||
}
|
||||
|
||||
@@ -6,16 +6,14 @@ import { getSessionUser, STATUS } from '@/lib/routing'
|
||||
import { getRoleLevel, ROLE_LEVELS } from '@/lib/constants'
|
||||
import { PackageSchemas } from '@/lib/validation'
|
||||
|
||||
interface RouteParams {
|
||||
params: {
|
||||
packageId: string
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(request: NextRequest, { params }: RouteParams) {
|
||||
export async function DELETE(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ packageId: string }> }
|
||||
) {
|
||||
try {
|
||||
const resolvedParams = await params
|
||||
// Validate packageId format
|
||||
const packageIdResult = PackageSchemas.packageId.safeParse(params.packageId)
|
||||
const packageIdResult = PackageSchemas.packageId.safeParse(resolvedParams.packageId)
|
||||
if (!packageIdResult.success) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Invalid package ID format' },
|
||||
@@ -44,7 +42,7 @@ export async function DELETE(request: NextRequest, { params }: RouteParams) {
|
||||
)
|
||||
}
|
||||
|
||||
await deletePackageData(params.packageId)
|
||||
await deletePackageData(resolvedParams.packageId)
|
||||
return NextResponse.json({ deleted: true })
|
||||
} catch (error) {
|
||||
console.error('Error deleting package data:', error)
|
||||
|
||||
@@ -5,16 +5,14 @@ import { getPackageData } from '@/lib/db/packages/get-package-data'
|
||||
import { getSessionUser, STATUS } from '@/lib/routing'
|
||||
import { PackageSchemas } from '@/lib/validation'
|
||||
|
||||
interface RouteParams {
|
||||
params: {
|
||||
packageId: string
|
||||
}
|
||||
}
|
||||
|
||||
export async function GET(request: NextRequest, { params }: RouteParams) {
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ packageId: string }> }
|
||||
) {
|
||||
try {
|
||||
const resolvedParams = await params
|
||||
// Validate packageId format
|
||||
const packageIdResult = PackageSchemas.packageId.safeParse(params.packageId)
|
||||
const packageIdResult = PackageSchemas.packageId.safeParse(resolvedParams.packageId)
|
||||
if (!packageIdResult.success) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Invalid package ID format' },
|
||||
@@ -32,7 +30,7 @@ export async function GET(request: NextRequest, { params }: RouteParams) {
|
||||
)
|
||||
}
|
||||
|
||||
const data = await getPackageData(params.packageId)
|
||||
const data = await getPackageData(resolvedParams.packageId)
|
||||
return NextResponse.json({ data })
|
||||
} catch (error) {
|
||||
console.error('Error fetching package data:', error)
|
||||
|
||||
@@ -12,16 +12,14 @@ type PackageDataPayload = {
|
||||
data?: PackageSeedData
|
||||
}
|
||||
|
||||
interface RouteParams {
|
||||
params: {
|
||||
packageId: string
|
||||
}
|
||||
}
|
||||
|
||||
export async function PUT(request: NextRequest, { params }: RouteParams) {
|
||||
export async function PUT(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ packageId: string }> }
|
||||
) {
|
||||
try {
|
||||
const resolvedParams = await params
|
||||
// Validate packageId format
|
||||
const packageIdResult = PackageSchemas.packageId.safeParse(params.packageId)
|
||||
const packageIdResult = PackageSchemas.packageId.safeParse(resolvedParams.packageId)
|
||||
if (!packageIdResult.success) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Invalid package ID format' },
|
||||
@@ -55,7 +53,7 @@ export async function PUT(request: NextRequest, { params }: RouteParams) {
|
||||
return NextResponse.json({ error: 'Package data is required' }, { status: 400 })
|
||||
}
|
||||
|
||||
await setPackageData(params.packageId, body.data)
|
||||
await setPackageData(resolvedParams.packageId, body.data)
|
||||
return NextResponse.json({ saved: true })
|
||||
} catch (error) {
|
||||
console.error('Error saving package data:', error)
|
||||
|
||||
Reference in New Issue
Block a user