cal.pub0.org/pages/api/bookings/index.ts

20 lines
527 B
TypeScript
Raw Normal View History

2022-03-30 12:17:55 +00:00
import type { NextApiRequest, NextApiResponse } from "next";
2022-03-26 21:29:30 +00:00
2022-03-30 12:17:55 +00:00
import prisma from "@calcom/prisma";
2022-03-26 21:29:30 +00:00
import { Booking } from "@calcom/prisma/client";
type ResponseData = {
data?: Booking[];
error?: unknown;
};
export default async function booking(req: NextApiRequest, res: NextApiResponse<ResponseData>) {
try {
2022-03-28 14:05:00 +00:00
const data = await prisma.booking.findMany();
res.status(200).json({ data });
2022-03-26 21:29:30 +00:00
} catch (error) {
// FIXME: Add zod for validation/error handling
res.status(400).json({ error: error });
}
}