import type { NextApiRequest } from "next"; import { defaultResponder } from "@calcom/lib/server"; import { schemaBookingReadPublic } from "@lib/validations/booking"; import { schemaQueryIdParseInt } from "@lib/validations/shared/queryIdTransformParseInt"; /** * @swagger * /bookings/{id}: * get: * summary: Find a booking * operationId: getBookingById * parameters: * - in: path * name: id * schema: * type: integer * required: true * description: ID of the booking to get * tags: * - bookings * responses: * 200: * description: OK * 401: * description: Authorization information is missing or invalid. * 404: * description: Booking was not found */ export async function getHandler(req: NextApiRequest) { const { prisma, query } = req; const { id } = schemaQueryIdParseInt.parse(query); const booking = await prisma.booking.findUnique({ where: { id } }); return { booking: schemaBookingReadPublic.parse(booking) }; } export default defaultResponder(getHandler);