import { NextResponse } from "next/server"; import { resetMaestroPassword } from "@/lib/maestros"; import { ApiError } from "@/lib/errors"; import { withApiHandler } from "@/lib/api-handler"; import { logger } from "@/lib/logger"; const CTX = "maestros/[id]/reset-password"; 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 found = await resetMaestroPassword(maestroID); if (!found) { throw new ApiError("Not found", 404); } logger.info(CTX, "password reset", { id: maestroID, duration: Date.now() - t0, }); return NextResponse.json({ success: true }); } );