fix: update API route params for Next.js 15+ async params
Next.js 15+ changed dynamic route params to be async Promises. Updated all schedule API routes to await params before accessing id. Changes: - GET /api/sync/schedules/[id] - await params - PATCH /api/sync/schedules/[id] - await params - DELETE /api/sync/schedules/[id] - await params - POST /api/sync/schedules/[id]/trigger - await params This fixes TypeScript compilation errors during Docker build.
This commit is contained in:
parent
3db50d8531
commit
bac9797845
2 changed files with 12 additions and 8 deletions
|
|
@ -12,10 +12,11 @@ import { syncScheduler } from '@/lib/services/sync-scheduler';
|
|||
*/
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const schedule = await syncScheduler.getSchedule(params.id);
|
||||
const { id } = await params;
|
||||
const schedule = await syncScheduler.getSchedule(id);
|
||||
|
||||
if (!schedule) {
|
||||
return NextResponse.json(
|
||||
|
|
@ -45,12 +46,13 @@ export async function GET(
|
|||
*/
|
||||
export async function PATCH(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
const body = await request.json();
|
||||
|
||||
const schedule = await syncScheduler.updateSchedule(params.id, body);
|
||||
const schedule = await syncScheduler.updateSchedule(id, body);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
|
|
@ -73,10 +75,11 @@ export async function PATCH(
|
|||
*/
|
||||
export async function DELETE(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
await syncScheduler.deleteSchedule(params.id);
|
||||
const { id } = await params;
|
||||
await syncScheduler.deleteSchedule(id);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
|
|
|
|||
|
|
@ -12,10 +12,11 @@ import { syncScheduler } from '@/lib/services/sync-scheduler';
|
|||
*/
|
||||
export async function POST(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
await syncScheduler.triggerSchedule(params.id);
|
||||
const { id } = await params;
|
||||
await syncScheduler.triggerSchedule(id);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue