This commit is contained in:
Agusti Fernandez Pardo
2022-03-30 14:17:55 +02:00
parent 39ae2aed37
commit 1de7bc4146
126 changed files with 1240 additions and 992 deletions
+11 -14
View File
@@ -1,19 +1,16 @@
import { withValidation } from "next-validations";
import { z } from "zod";
const schemaApiKey = z
.object({
// We need to cast the date as strings as when we get it from the json response
// we serve in api it is a string too (JSON doesn't directly support Date types)
createdAt: z.date().optional().or(z.string().optional()),
expiresAt: z.date().optional(), // default is 30 days
note: z.string().min(1).optional(),
})
.strict(); // Adding strict so that we can disallow passing in extra fields
const withValidApiKey = withValidation({
schema: schemaApiKey,
import { _ApiKeyModel as ApiKey } from "@calcom/prisma/zod";
export const schemaApiKeyBodyParams = ApiKey.omit({ id: true, userId: true, createdAt: true });
export const schemaApiKeyPublic = ApiKey.omit({
id: true,
userId: true,
});
export const withValidApiKey = withValidation({
schema: schemaApiKeyBodyParams,
type: "Zod",
mode: "body",
});
export { schemaApiKey, withValidApiKey };