2022-06-10 18:38:46 +00:00
|
|
|
import type { NextApiRequest } from "next";
|
|
|
|
import { z } from "zod";
|
|
|
|
|
|
|
|
import { getUserAvailability } from "@calcom/core/getUserAvailability";
|
|
|
|
import { defaultResponder } from "@calcom/lib/server";
|
|
|
|
import { stringOrNumber } from "@calcom/prisma/zod-utils";
|
|
|
|
|
|
|
|
const availabilitySchema = z.object({
|
|
|
|
user: z.string(),
|
|
|
|
dateFrom: z.string(),
|
|
|
|
dateTo: z.string(),
|
|
|
|
eventTypeId: stringOrNumber.optional(),
|
|
|
|
});
|
|
|
|
|
|
|
|
async function handler(req: NextApiRequest) {
|
|
|
|
const { user: username, eventTypeId, dateTo, dateFrom } = availabilitySchema.parse(req.query);
|
|
|
|
return getUserAvailability({
|
|
|
|
username,
|
|
|
|
dateFrom,
|
|
|
|
dateTo,
|
2022-05-12 01:49:21 +00:00
|
|
|
eventTypeId,
|
2021-09-14 08:45:28 +00:00
|
|
|
});
|
2021-04-16 02:09:22 +00:00
|
|
|
}
|
2022-06-10 18:38:46 +00:00
|
|
|
|
|
|
|
export default defaultResponder(handler);
|