Refactors event-types endpoints (#181)

refs #175
This commit is contained in:
Omar López authored and GitHub committed 2022-10-11 14:14:03 -06:00
1 parent 4ba0395efa
commit f13694fd13
11 files changed
+340 -331

No files matched your search

+8 -4
View File
@@ -1,18 +1,22 @@
import { withValidation } from "next-validations";
import { z } from "zod";
import { stringOrNumber } from "@calcom/prisma/zod-utils";
import { baseApiParams } from "./baseApiParams";
// Extracted out as utility function so can be reused
// at different endpoints that require this validation.
export const schemaQueryUserId = baseApiParams
.extend({
userId: z
.string()
.regex(/^\d+$/)
.transform((id) => parseInt(id)),
userId: stringOrNumber,
})
.strict();
export const schemaQuerySingleOrMultipleUserIds = z.object({
userId: z.union([stringOrNumber, z.array(stringOrNumber)]),
});
export const withValidQueryUserId = withValidation({
schema: schemaQueryUserId,
type: "Zod",