2022-10-20 23:28:02 +00:00
|
|
|
import type { NextApiRequest } from "next";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2022-10-20 23:28:02 +00:00
|
|
|
import handleCancelBooking from "@calcom/features/bookings/lib/handleCancelBooking";
|
2022-10-12 13:04:51 +00:00
|
|
|
import { getSession } from "@calcom/lib/auth";
|
2022-10-20 23:28:02 +00:00
|
|
|
import { defaultResponder, defaultHandler } from "@calcom/lib/server";
|
2021-06-06 01:51:24 +00:00
|
|
|
|
2022-10-20 23:28:02 +00:00
|
|
|
async function handler(req: NextApiRequest & { userId?: number }) {
|
2022-07-19 23:29:52 +00:00
|
|
|
const session = await getSession({ req });
|
2022-10-20 23:28:02 +00:00
|
|
|
/* To mimic API behavior */
|
|
|
|
req.userId = session?.user?.id;
|
|
|
|
return await handleCancelBooking(req);
|
2021-07-15 21:34:55 +00:00
|
|
|
}
|
2022-07-19 23:29:52 +00:00
|
|
|
|
|
|
|
export default defaultHandler({
|
|
|
|
DELETE: Promise.resolve({ default: defaultResponder(handler) }),
|
|
|
|
POST: Promise.resolve({ default: defaultResponder(handler) }),
|
|
|
|
});
|