fix availabilities spelling

pull/9078/head
Agusti Fernandez Pardo 2022-04-04 21:53:03 +02:00
parent 23698462b8
commit 5b3f9ee95c
4 changed files with 13 additions and 36 deletions

View File

@ -70,7 +70,7 @@ export type AttendeesResponse = BaseResponse & {
export type AvailabilityResponse = BaseResponse & { export type AvailabilityResponse = BaseResponse & {
data?: Partial<Availability>; data?: Partial<Availability>;
}; };
export type AvailabilitysResponse = BaseResponse & { export type AvailabilitiesResponse = BaseResponse & {
data?: Partial<Availability>[]; data?: Partial<Availability>[];
}; };

View File

@ -1,23 +0,0 @@
import { withValidation } from "next-validations";
import { z } from "zod";
import { _ApiKeyModel as ApiKey } from "@calcom/prisma/zod";
export const schemaApiKeyBaseBodyParams = ApiKey.omit({ id: true, userId: true, createdAt: true }).partial();
const schemaApiKeyRequiredParams = z.object({
email: z.string().email(),
});
export const schemaApiKeyBodyParams = schemaApiKeyBaseBodyParams.merge(schemaApiKeyRequiredParams);
export const schemaApiKeyPublic = ApiKey.omit({
id: true,
userId: true,
});
export const withValidApiKey = withValidation({
schema: schemaApiKeyBodyParams,
type: "Zod",
mode: "body",
});

View File

@ -3,35 +3,35 @@ import type { NextApiRequest, NextApiResponse } from "next";
import prisma from "@calcom/prisma"; import prisma from "@calcom/prisma";
import { withMiddleware } from "@lib/helpers/withMiddleware"; import { withMiddleware } from "@lib/helpers/withMiddleware";
import { AvailabilitysResponse } from "@lib/types"; import { AvailabilitiesResponse } from "@lib/types";
import { schemaAvailabilityPublic } from "@lib/validations/availability"; import { schemaAvailabilityPublic } from "@lib/validations/availability";
/** /**
* @swagger * @swagger
* /api/availabilites: * /api/availabilities:
* get: * get:
* summary: Get all availabilites * summary: Get all availabilities
* tags: * tags:
* - availabilites * - availabilities
* responses: * responses:
* 200: * 200:
* description: OK * description: OK
* 401: * 401:
* description: Authorization information is missing or invalid. * description: Authorization information is missing or invalid.
* 404: * 404:
* description: No availabilites were found * description: No availabilities were found
*/ */
async function allAvailabilitys(_: NextApiRequest, res: NextApiResponse<AvailabilitysResponse>) { async function allAvailabilities(_: NextApiRequest, res: NextApiResponse<AvailabilitiesResponse>) {
const availabilites = await prisma.availability.findMany(); const availabilities = await prisma.availability.findMany();
const data = availabilites.map((availability) => schemaAvailabilityPublic.parse(availability)); const data = availabilities.map((availability) => schemaAvailabilityPublic.parse(availability));
if (data) res.status(200).json({ data }); if (data) res.status(200).json({ data });
else else
(error: Error) => (error: Error) =>
res.status(404).json({ res.status(404).json({
message: "No Availabilitys were found", message: "No Availabilities were found",
error, error,
}); });
} }
export default withMiddleware("HTTP_GET")(allAvailabilitys); export default withMiddleware("HTTP_GET")(allAvailabilities);

View File

@ -12,7 +12,7 @@ import {
/** /**
* @swagger * @swagger
* /api/availabilites/new: * /api/availabilities/new:
* post: * post:
* summary: Creates a new availability * summary: Creates a new availability
* requestBody: * requestBody:
@ -23,7 +23,7 @@ import {
* schema: * schema:
* $ref: '#/components/schemas/Availability' * $ref: '#/components/schemas/Availability'
* tags: * tags:
* - availabilites * - availabilities
* responses: * responses:
* 201: * 201:
* description: OK, availability created * description: OK, availability created