Files
calendar/apps/web/pages/api/cancel.ts
T
5f78eceb89 Abstracting booking cancellation (#5105)
* Abstracting booking cancellation

* Tweaking to use id and not uid

* Standardizing http errors

* Moving schema to prisma zod-utils

* Update apps/web/pages/api/cancel.ts

Co-authored-by: Alex van Andel <me@alexvanandel.com>

* Cancel only for delete and post verbs

* Make cancellation work with uid, and id

Co-authored-by: Alex van Andel <me@alexvanandel.com>
2022-10-20 23:28:02 +00:00

18 lines
638 B
TypeScript

import type { NextApiRequest } from "next";
import handleCancelBooking from "@calcom/features/bookings/lib/handleCancelBooking";
import { getSession } from "@calcom/lib/auth";
import { defaultResponder, defaultHandler } from "@calcom/lib/server";
async function handler(req: NextApiRequest & { userId?: number }) {
const session = await getSession({ req });
/* To mimic API behavior */
req.userId = session?.user?.id;
return await handleCancelBooking(req);
}
export default defaultHandler({
DELETE: Promise.resolve({ default: defaultResponder(handler) }),
POST: Promise.resolve({ default: defaultResponder(handler) }),
});