fix availabilities spelling
parent
23698462b8
commit
5b3f9ee95c
|
@ -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>[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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",
|
|
||||||
});
|
|
|
@ -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);
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue