2022-06-10 18:38:46 +00:00
|
|
|
import type { NextApiRequest } from "next";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2022-10-12 13:04:51 +00:00
|
|
|
import handleNewBooking from "@calcom/features/bookings/lib/handleNewBooking";
|
|
|
|
import { getSession } from "@calcom/lib/auth";
|
|
|
|
import { defaultResponder } from "@calcom/lib/server";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2022-10-12 13:04:51 +00:00
|
|
|
async function handler(req: NextApiRequest & { userId?: number }) {
|
2022-08-05 17:08:47 +00:00
|
|
|
const session = await getSession({ req });
|
2022-11-25 14:24:44 +00:00
|
|
|
/* To mimic API behavior and comply with types */
|
|
|
|
req.userId = session?.user?.id || -1;
|
2023-03-02 18:15:28 +00:00
|
|
|
const booking = await handleNewBooking(req, {
|
|
|
|
isNotAnApiCall: true,
|
|
|
|
});
|
2022-06-10 18:38:46 +00:00
|
|
|
return booking;
|
2021-09-14 08:45:28 +00:00
|
|
|
}
|
2021-12-03 16:18:31 +00:00
|
|
|
|
2022-06-10 18:38:46 +00:00
|
|
|
export default defaultResponder(handler);
|