import { NextResponse } from "next/server"; import { withAuth } from "@/lib/api-auth"; import { apiError, handleApiError } from "@/lib/api-errors"; import { EndpointError, testEndpoint } from "@/lib/endpoints"; export const dynamic = "force-dynamic"; /** Test a new endpoint's form values before saving. */ export const POST = withAuth(async (req) => { try { return NextResponse.json(await testEndpoint(null, await req.json())); } catch (err) { if (err instanceof EndpointError) return apiError(err.status, err.code, err.message); return handleApiError(err); } });