import { NextResponse } from "next/server"; import { createExtensionRequest } from "@/lib/extension-requests"; import { ApiError } from "@/lib/errors"; import { withApiHandler } from "@/lib/api-handler"; import { logger } from "@/lib/logger"; const CTX = "maestros/[id]/extension-requests"; export const POST = withApiHandler<{ id: string }>( CTX, async (_request, { params, t0 }) => { const { id } = await params; const maestroID = Number(id); if (!Number.isInteger(maestroID) || maestroID <= 0) { throw new ApiError("Invalid maestro id", 400); } const result = await createExtensionRequest(maestroID); logger.info(CTX, "created", { maestroID, maestroExtensionID: result.maestroExtensionID, duration: Date.now() - t0, }); return NextResponse.json(result, { status: 201 }); } );