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-12 13:04:51 +00:00
|
|
|
import handleNewBooking from "@calcom/features/bookings/lib/handleNewBooking";
|
|
|
|
import { defaultResponder } from "@calcom/lib/server";
|
2021-09-22 19:52:38 +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;
|
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);
|