2023-03-10 23:45:24 +00:00
|
|
|
import type { NextApiRequest, NextApiResponse } from "next";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2023-03-10 23:45:24 +00:00
|
|
|
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
2022-10-20 23:28:02 +00:00
|
|
|
import handleCancelBooking from "@calcom/features/bookings/lib/handleCancelBooking";
|
|
|
|
import { defaultResponder, defaultHandler } from "@calcom/lib/server";
|
2021-06-06 01:51:24 +00:00
|
|
|
|
2023-03-10 23:45:24 +00:00
|
|
|
async function handler(req: NextApiRequest & { userId?: number }, res: NextApiResponse) {
|
|
|
|
const session = await getServerSession({ req, res });
|
2022-11-25 14:24:44 +00:00
|
|
|
/* To mimic API behavior and comply with types */
|
|
|
|
req.userId = session?.user?.id || -1;
|
2022-10-20 23:28:02 +00:00
|
|
|
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) }),
|
|
|
|
});
|