diff --git a/pages/api/attendees/[id]/_auth-middleware.ts b/pages/api/attendees/[id]/_auth-middleware.ts index b1b474b506..ab27cf266e 100644 --- a/pages/api/attendees/[id]/_auth-middleware.ts +++ b/pages/api/attendees/[id]/_auth-middleware.ts @@ -1,7 +1,6 @@ import type { NextApiRequest } from "next"; import { HttpError } from "@calcom/lib/http-error"; -import { defaultResponder } from "@calcom/lib/server"; import { schemaQueryIdParseInt } from "@lib/validations/shared/queryIdTransformParseInt"; @@ -18,4 +17,4 @@ async function authMiddleware(req: NextApiRequest) { if (!attendee) throw new HttpError({ statusCode: 401, message: "Unauthorized" }); } -export default defaultResponder(authMiddleware); +export default authMiddleware; diff --git a/pages/api/attendees/[id]/index.ts b/pages/api/attendees/[id]/index.ts index 4b740bcbb5..7d92ee2906 100644 --- a/pages/api/attendees/[id]/index.ts +++ b/pages/api/attendees/[id]/index.ts @@ -1,16 +1,18 @@ import { NextApiRequest, NextApiResponse } from "next"; -import { defaultHandler } from "@calcom/lib/server"; +import { defaultHandler, defaultResponder } from "@calcom/lib/server"; import { withMiddleware } from "@lib/helpers/withMiddleware"; import authMiddleware from "./_auth-middleware"; -export default withMiddleware("HTTP_GET_DELETE_PATCH")(async (req: NextApiRequest, res: NextApiResponse) => { - await authMiddleware(req, res); - return defaultHandler({ - GET: import("./_get"), - PATCH: import("./_patch"), - DELETE: import("./_delete"), - })(req, res); -}); +export default withMiddleware("HTTP_GET_DELETE_PATCH")( + defaultResponder(async (req: NextApiRequest, res: NextApiResponse) => { + await authMiddleware(req); + return defaultHandler({ + GET: import("./_get"), + PATCH: import("./_patch"), + DELETE: import("./_delete"), + })(req, res); + }) +); diff --git a/pages/api/availabilities/[id]/_auth-middleware.ts b/pages/api/availabilities/[id]/_auth-middleware.ts index 44378f90a3..4197944cf9 100644 --- a/pages/api/availabilities/[id]/_auth-middleware.ts +++ b/pages/api/availabilities/[id]/_auth-middleware.ts @@ -1,10 +1,8 @@ import type { NextApiRequest } from "next"; -import { defaultResponder } from "@calcom/lib/server"; - import { schemaQueryIdParseInt } from "@lib/validations/shared/queryIdTransformParseInt"; -export async function authMiddleware(req: NextApiRequest) { +async function authMiddleware(req: NextApiRequest) { const { userId, prisma, isAdmin, query } = req; const { id } = schemaQueryIdParseInt.parse(query); /** Admins can skip the ownership verification */ @@ -18,4 +16,4 @@ export async function authMiddleware(req: NextApiRequest) { }); } -export default defaultResponder(authMiddleware); +export default authMiddleware; diff --git a/pages/api/availabilities/[id]/index.ts b/pages/api/availabilities/[id]/index.ts index 4b740bcbb5..7d92ee2906 100644 --- a/pages/api/availabilities/[id]/index.ts +++ b/pages/api/availabilities/[id]/index.ts @@ -1,16 +1,18 @@ import { NextApiRequest, NextApiResponse } from "next"; -import { defaultHandler } from "@calcom/lib/server"; +import { defaultHandler, defaultResponder } from "@calcom/lib/server"; import { withMiddleware } from "@lib/helpers/withMiddleware"; import authMiddleware from "./_auth-middleware"; -export default withMiddleware("HTTP_GET_DELETE_PATCH")(async (req: NextApiRequest, res: NextApiResponse) => { - await authMiddleware(req, res); - return defaultHandler({ - GET: import("./_get"), - PATCH: import("./_patch"), - DELETE: import("./_delete"), - })(req, res); -}); +export default withMiddleware("HTTP_GET_DELETE_PATCH")( + defaultResponder(async (req: NextApiRequest, res: NextApiResponse) => { + await authMiddleware(req); + return defaultHandler({ + GET: import("./_get"), + PATCH: import("./_patch"), + DELETE: import("./_delete"), + })(req, res); + }) +); diff --git a/pages/api/bookings/[id]/_auth-middleware.ts b/pages/api/bookings/[id]/_auth-middleware.ts index ead390f413..c8ea34e335 100644 --- a/pages/api/bookings/[id]/_auth-middleware.ts +++ b/pages/api/bookings/[id]/_auth-middleware.ts @@ -1,11 +1,10 @@ import type { NextApiRequest } from "next"; import { HttpError } from "@calcom/lib/http-error"; -import { defaultResponder } from "@calcom/lib/server"; import { schemaQueryIdParseInt } from "@lib/validations/shared/queryIdTransformParseInt"; -export async function authMiddleware(req: NextApiRequest) { +async function authMiddleware(req: NextApiRequest) { const { userId, prisma, isAdmin, query } = req; const { id } = schemaQueryIdParseInt.parse(query); const userWithBookings = await prisma.user.findUnique({ @@ -22,4 +21,4 @@ export async function authMiddleware(req: NextApiRequest) { } } -export default defaultResponder(authMiddleware); +export default authMiddleware; diff --git a/pages/api/bookings/[id]/index.ts b/pages/api/bookings/[id]/index.ts index 4b740bcbb5..7d92ee2906 100644 --- a/pages/api/bookings/[id]/index.ts +++ b/pages/api/bookings/[id]/index.ts @@ -1,16 +1,18 @@ import { NextApiRequest, NextApiResponse } from "next"; -import { defaultHandler } from "@calcom/lib/server"; +import { defaultHandler, defaultResponder } from "@calcom/lib/server"; import { withMiddleware } from "@lib/helpers/withMiddleware"; import authMiddleware from "./_auth-middleware"; -export default withMiddleware("HTTP_GET_DELETE_PATCH")(async (req: NextApiRequest, res: NextApiResponse) => { - await authMiddleware(req, res); - return defaultHandler({ - GET: import("./_get"), - PATCH: import("./_patch"), - DELETE: import("./_delete"), - })(req, res); -}); +export default withMiddleware("HTTP_GET_DELETE_PATCH")( + defaultResponder(async (req: NextApiRequest, res: NextApiResponse) => { + await authMiddleware(req); + return defaultHandler({ + GET: import("./_get"), + PATCH: import("./_patch"), + DELETE: import("./_delete"), + })(req, res); + }) +);