40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import type { NextApiRequest } from "next";
|
|
|
|
import { defaultResponder } from "@calcom/lib/server";
|
|
|
|
import { schemaAttendeeReadPublic } from "@lib/validations/attendee";
|
|
import { schemaQueryIdParseInt } from "@lib/validations/shared/queryIdTransformParseInt";
|
|
|
|
/**
|
|
* @swagger
|
|
* /attendees/{id}:
|
|
* get:
|
|
* operationId: getAttendeeById
|
|
* summary: Find an attendee
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* schema:
|
|
* type: integer
|
|
* required: true
|
|
* description: ID of the attendee to get
|
|
* example: 3
|
|
* tags:
|
|
* - attendees
|
|
* responses:
|
|
* 200:
|
|
* description: OK
|
|
* 401:
|
|
* description: Authorization information is missing or invalid.
|
|
* 404:
|
|
* description: Attendee was not found
|
|
*/
|
|
export async function getHandler(req: NextApiRequest) {
|
|
const { prisma, query } = req;
|
|
const { id } = schemaQueryIdParseInt.parse(query);
|
|
const attendee = await prisma.attendee.findUnique({ where: { id } });
|
|
return { attendee: schemaAttendeeReadPublic.parse(attendee) };
|
|
}
|
|
|
|
export default defaultResponder(getHandler);
|