remove unnecessary await on all getCalcomUserId() calls
This commit is contained in:
1 parent
b0c0e9fb4c
commit
18c1a2f026
11 files changed
+12
-12
No files matched your search
@@ -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 },
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -47,7 +47,7 @@ async function createOrlistAllAvailabilities(
|
||||
res: NextApiResponse<AvailabilitiesResponse | AvailabilityResponse>
|
||||
) {
|
||||
const { method } = req;
|
||||
const userId = await getCalcomUserId(res);
|
||||
const userId = getCalcomUserId(res);
|
||||
|
||||
if (method === "GET") {
|
||||
const data = await prisma.availability.findMany({ where: { userId } });
|
||||
|
||||
@@ -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 },
|
||||
|
||||
@@ -46,7 +46,7 @@ async function createOrlistAllBookingReferences(
|
||||
res: NextApiResponse<BookingReferencesResponse | BookingReferenceResponse>
|
||||
) {
|
||||
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 },
|
||||
|
||||
@@ -91,7 +91,7 @@ export async function bookingById(req: NextApiRequest, res: NextApiResponse<Book
|
||||
const safeQuery = schemaQueryIdParseInt.safeParse(query);
|
||||
const safeBody = schemaBookingBodyParams.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 },
|
||||
|
||||
@@ -43,7 +43,7 @@ async function createOrlistAllBookings(
|
||||
res: NextApiResponse<BookingsResponse | BookingResponse>
|
||||
) {
|
||||
const { method } = req;
|
||||
const userId = await getCalcomUserId(res);
|
||||
const userId = getCalcomUserId(res);
|
||||
|
||||
if (method === "GET") {
|
||||
const data = await prisma.booking.findMany({ where: { userId } });
|
||||
|
||||
@@ -97,7 +97,7 @@ export async function eventTypeById(req: NextApiRequest, res: NextApiResponse<Ev
|
||||
const safeQuery = schemaQueryIdParseInt.safeParse(query);
|
||||
const safeBody = schemaEventTypeBodyParams.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.eventType.findMany({ where: { userId } });
|
||||
const userEventTypes = data.map((eventType) => eventType.id);
|
||||
if (userEventTypes.includes(safeQuery.data.id)) {
|
||||
|
||||
@@ -47,7 +47,7 @@ async function createOrlistAllEventTypes(
|
||||
res: NextApiResponse<EventTypesResponse | EventTypeResponse>
|
||||
) {
|
||||
const { method } = req;
|
||||
const userId = await getCalcomUserId(res);
|
||||
const userId = getCalcomUserId(res);
|
||||
|
||||
if (method === "GET") {
|
||||
const data = await prisma.eventType.findMany({ where: { userId } });
|
||||
|
||||
@@ -38,7 +38,7 @@ import {
|
||||
export async function paymentById(req: NextApiRequest, res: NextApiResponse<PaymentResponse>) {
|
||||
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({
|
||||
|
||||
@@ -25,7 +25,7 @@ import { schemaPaymentPublic } from "@lib/validations/payment";
|
||||
* description: No payments were found
|
||||
*/
|
||||
async function allPayments(_: NextApiRequest, res: NextApiResponse<PaymentsResponse>) {
|
||||
const userId = await getCalcomUserId(res);
|
||||
const userId = getCalcomUserId(res);
|
||||
|
||||
const userWithBookings = await prisma.user.findUnique({
|
||||
where: { id: userId },
|
||||
|
||||
Reference in new issue
Block a user