Merge branch 'main' into production
commit
e15100571e
|
@ -2,9 +2,15 @@
|
|||
// This makes our @calcom/prisma package from the monorepo to be transpiled and usable by API
|
||||
const withTM = require("next-transpile-modules")([
|
||||
"@calcom/app-store",
|
||||
"@calcom/prisma",
|
||||
"@calcom/lib",
|
||||
"@calcom/core",
|
||||
"@calcom/ee",
|
||||
"@calcom/lib",
|
||||
"@calcom/prisma",
|
||||
"@calcom/stripe",
|
||||
"@calcom/ui",
|
||||
"@calcom/emails",
|
||||
"@calcom/embed-core",
|
||||
"@calcom/embed-snippet",
|
||||
]);
|
||||
|
||||
module.exports = withTM({
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
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({
|
||||
userId: stringOrNumber.optional(),
|
||||
username: z.string().optional(),
|
||||
dateFrom: z.string(),
|
||||
dateTo: z.string(),
|
||||
eventTypeId: stringOrNumber.optional(),
|
||||
})
|
||||
.refine((data) => !!data.username || !!data.userId, "Either username or userId should be filled in.");
|
||||
|
||||
async function handler(req: NextApiRequest) {
|
||||
const { username, userId, eventTypeId, dateTo, dateFrom } = availabilitySchema.parse(req.query);
|
||||
return getUserAvailability({
|
||||
username,
|
||||
dateFrom,
|
||||
dateTo,
|
||||
eventTypeId,
|
||||
userId,
|
||||
});
|
||||
}
|
||||
|
||||
export default defaultResponder(handler);
|
|
@ -0,0 +1,5 @@
|
|||
import { defaultHandler } from "@calcom/lib/server";
|
||||
|
||||
export default defaultHandler({
|
||||
GET: import("./_get"),
|
||||
});
|
Loading…
Reference in New Issue