From 18c1a2f026bc1106e74c0e41ba108c956df9e6c0 Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Thu, 21 Apr 2022 00:55:41 +0200 Subject: [PATCH] remove unnecessary await on all getCalcomUserId() calls --- pages/api/attendees/index.ts | 2 +- pages/api/availabilities/[id].ts | 2 +- pages/api/availabilities/index.ts | 2 +- pages/api/booking-references/[id].ts | 2 +- pages/api/booking-references/index.ts | 4 ++-- pages/api/bookings/[id].ts | 2 +- pages/api/bookings/index.ts | 2 +- pages/api/event-types/[id].ts | 2 +- pages/api/event-types/index.ts | 2 +- pages/api/payments/[id].ts | 2 +- pages/api/payments/index.ts | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pages/api/attendees/index.ts b/pages/api/attendees/index.ts index ed0707d636..d96fe3bca4 100644 --- a/pages/api/attendees/index.ts +++ b/pages/api/attendees/index.ts @@ -68,7 +68,7 @@ async function createOrlistAllAttendees( throw new Error("Invalid request body", safe.error); } const bookingId = safe.data.bookingId; - const userId = await getCalcomUserId(res); + const userId = getCalcomUserId(res); const userWithBookings = await prisma.user.findUnique({ where: { id: userId }, include: { bookings: true }, diff --git a/pages/api/availabilities/[id].ts b/pages/api/availabilities/[id].ts index 90d0f72fc1..bdb1215f74 100644 --- a/pages/api/availabilities/[id].ts +++ b/pages/api/availabilities/[id].ts @@ -97,7 +97,7 @@ export async function availabilityById(req: NextApiRequest, res: NextApiResponse const safeQuery = schemaQueryIdParseInt.safeParse(query); const safeBody = schemaAvailabilityBodyParams.safeParse(body); if (!safeQuery.success) throw new Error("Invalid request query", safeQuery.error); - const userId = await getCalcomUserId(res); + const userId = getCalcomUserId(res); const data = await prisma.availability.findMany({ where: { userId } }); const availabiltiesIds = data.map((availability) => availability.id); if (availabiltiesIds.includes(safeQuery.data.id)) { diff --git a/pages/api/availabilities/index.ts b/pages/api/availabilities/index.ts index bcd904ce95..63ae75db49 100644 --- a/pages/api/availabilities/index.ts +++ b/pages/api/availabilities/index.ts @@ -47,7 +47,7 @@ async function createOrlistAllAvailabilities( res: NextApiResponse ) { const { method } = req; - const userId = await getCalcomUserId(res); + const userId = getCalcomUserId(res); if (method === "GET") { const data = await prisma.availability.findMany({ where: { userId } }); diff --git a/pages/api/booking-references/[id].ts b/pages/api/booking-references/[id].ts index 3067dc3c15..9a1b40089b 100644 --- a/pages/api/booking-references/[id].ts +++ b/pages/api/booking-references/[id].ts @@ -98,7 +98,7 @@ export async function bookingReferenceById( const safeQuery = schemaQueryIdParseInt.safeParse(query); const safeBody = schemaBookingReferenceBodyParams.safeParse(body); if (!safeQuery.success) throw new Error("Invalid request query", safeQuery.error); - const userId = await getCalcomUserId(res); + const userId = getCalcomUserId(res); const userWithBookings = await prisma.user.findUnique({ where: { id: userId }, include: { bookings: true }, diff --git a/pages/api/booking-references/index.ts b/pages/api/booking-references/index.ts index d256936ce5..9ceedeed30 100644 --- a/pages/api/booking-references/index.ts +++ b/pages/api/booking-references/index.ts @@ -46,7 +46,7 @@ async function createOrlistAllBookingReferences( res: NextApiResponse ) { const { method } = req; - const userId = await getCalcomUserId(res); + const userId = getCalcomUserId(res); const userWithBookings = await prisma.user.findUnique({ where: { id: userId }, include: { bookings: true }, @@ -72,7 +72,7 @@ async function createOrlistAllBookingReferences( } // const booking_reference = schemaBookingReferencePublic.parse(data); - const userId = await getCalcomUserId(res); + const userId = getCalcomUserId(res); const userWithBookings = await prisma.user.findUnique({ where: { id: userId }, include: { bookings: true }, diff --git a/pages/api/bookings/[id].ts b/pages/api/bookings/[id].ts index e3e56b9a36..af6a379158 100644 --- a/pages/api/bookings/[id].ts +++ b/pages/api/bookings/[id].ts @@ -91,7 +91,7 @@ export async function bookingById(req: NextApiRequest, res: NextApiResponse ) { const { method } = req; - const userId = await getCalcomUserId(res); + const userId = getCalcomUserId(res); if (method === "GET") { const data = await prisma.booking.findMany({ where: { userId } }); diff --git a/pages/api/event-types/[id].ts b/pages/api/event-types/[id].ts index c19822d65b..dc7535cd5a 100644 --- a/pages/api/event-types/[id].ts +++ b/pages/api/event-types/[id].ts @@ -97,7 +97,7 @@ export async function eventTypeById(req: NextApiRequest, res: NextApiResponse eventType.id); if (userEventTypes.includes(safeQuery.data.id)) { diff --git a/pages/api/event-types/index.ts b/pages/api/event-types/index.ts index cd883d719c..fc6a2a35f7 100644 --- a/pages/api/event-types/index.ts +++ b/pages/api/event-types/index.ts @@ -47,7 +47,7 @@ async function createOrlistAllEventTypes( res: NextApiResponse ) { const { method } = req; - const userId = await getCalcomUserId(res); + const userId = getCalcomUserId(res); if (method === "GET") { const data = await prisma.eventType.findMany({ where: { userId } }); diff --git a/pages/api/payments/[id].ts b/pages/api/payments/[id].ts index f196b4cac0..295803ca76 100644 --- a/pages/api/payments/[id].ts +++ b/pages/api/payments/[id].ts @@ -38,7 +38,7 @@ import { export async function paymentById(req: NextApiRequest, res: NextApiResponse) { const { method, query } = req; const safeQuery = schemaQueryIdParseInt.safeParse(query); - const userId = await getCalcomUserId(res); + const userId = getCalcomUserId(res); if (safeQuery.success && method === "GET") { const userWithBookings = await prisma.user.findUnique({ diff --git a/pages/api/payments/index.ts b/pages/api/payments/index.ts index 20028df180..bb2c132c0c 100644 --- a/pages/api/payments/index.ts +++ b/pages/api/payments/index.ts @@ -25,7 +25,7 @@ import { schemaPaymentPublic } from "@lib/validations/payment"; * description: No payments were found */ async function allPayments(_: NextApiRequest, res: NextApiResponse) { - const userId = await getCalcomUserId(res); + const userId = getCalcomUserId(res); const userWithBookings = await prisma.user.findUnique({ where: { id: userId },