* update oauth tests * fix parseRequestData * add logging * add fallback * use ?? * updates * use parseUrlFormData in saml/callback * update tests * fix * remove log * update * any -> unknown * use HttpErrors * addressed * unknown -> any * feat: Add entry report wrapper to every api route in appDir * fix * fix unit test * fix
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { defaultResponderForAppDir } from "app/api/defaultResponderForAppDir";
|
|
import { cookies, headers } from "next/headers";
|
|
import { NextResponse } from "next/server";
|
|
import type { NextRequest } from "next/server";
|
|
|
|
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
|
import handleCancelBooking from "@calcom/features/bookings/lib/handleCancelBooking";
|
|
|
|
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
|
|
|
|
async function handler(req: NextRequest) {
|
|
let appDirRequestBody;
|
|
try {
|
|
appDirRequestBody = await req.json();
|
|
} catch (error) {
|
|
return NextResponse.json({ success: false, message: "Invalid JSON" }, { status: 400 });
|
|
}
|
|
const session = await getServerSession({ req: buildLegacyRequest(headers(), cookies()) });
|
|
const result = await handleCancelBooking({
|
|
appDirRequestBody,
|
|
userId: session?.user?.id || -1,
|
|
});
|
|
|
|
const statusCode = result.success ? 200 : 400;
|
|
|
|
return NextResponse.json(result, { status: statusCode });
|
|
}
|
|
|
|
export const DELETE = defaultResponderForAppDir(handler);
|
|
export const POST = defaultResponderForAppDir(handler);
|