23 lines
860 B
TypeScript
23 lines
860 B
TypeScript
import type { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
|
import handleInstantMeeting from "@calcom/features/instant-meeting/handleInstantMeeting";
|
|
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
|
|
import getIP from "@calcom/lib/getIP";
|
|
import { defaultResponder } from "@calcom/lib/server";
|
|
|
|
async function handler(req: NextApiRequest & { userId?: number }, res: NextApiResponse) {
|
|
const userIp = getIP(req);
|
|
|
|
await checkRateLimitAndThrowError({
|
|
rateLimitingType: "core",
|
|
identifier: `instant.event-${userIp}`,
|
|
});
|
|
|
|
const session = await getServerSession({ req, res });
|
|
req.userId = session?.user?.id || -1;
|
|
const booking = await handleInstantMeeting(req);
|
|
return booking;
|
|
}
|
|
export default defaultResponder(handler);
|