Skip to content

Scheduling infrastructure for absolutely everyone.

fix: main merging issues

Agusti Fernandez Pardo5b28e9ec1c8c
diff --git a/lib/helpers/extendRequest.ts b/lib/helpers/extendRequest.ts
index 52af6da5444..8ed3ee0571c 100644
--- a/lib/helpers/extendRequest.ts
+++ b/lib/helpers/extendRequest.ts
@@ -18,6 +18,5 @@ declare module "next" {
}
}
export const extendRequest: NextMiddleware = async (req, res, next) => {
- // @note: just an empty middleware, we care about extending the next api request types only.
await next();
};
diff --git a/lib/helpers/withMiddleware.ts b/lib/helpers/withMiddleware.ts
index 05b21cbf0d6..ab6d5cb79e9 100644
--- a/lib/helpers/withMiddleware.ts
+++ b/lib/helpers/withMiddleware.ts
@@ -29,7 +29,7 @@ const withMiddleware = label(
sentry: captureErrors,
},
// The order here, determines the order of execution, put customPrismaClient before verifyApiKey always.
- ["sentry", "customPrismaClient", "verifyApiKey", "addRequestId", "extendRequest"] // <-- Provide a list of middleware to call automatically
+ ["extendRequest", "sentry", "customPrismaClient", "verifyApiKey", "addRequestId"] // <-- Provide a list of middleware to call automatically
);
export { withMiddleware };
diff --git a/next.config.js b/next.config.js
index 22ff466595b..939eba2374a 100644
--- a/next.config.js
+++ b/next.config.js
@@ -3,6 +3,7 @@
const withTM = require("next-transpile-modules")([
"@calcom/app-store",
"@calcom/core",
+ "@calcom/console",
"@calcom/ee",
"@calcom/lib",
"@calcom/prisma",
diff --git a/pages/api/availabilities/[id].ts b/pages/api/availabilities/[id].ts
index fe621829787..1d4b6ed4a1c 100644
--- a/pages/api/availabilities/[id].ts
+++ b/pages/api/availabilities/[id].ts
@@ -1,6 +1,6 @@
import type { NextApiRequest, NextApiResponse } from "next";
-// import { withMiddleware } from "@lib/helpers/withMiddleware";
+import { withMiddleware } from "@lib/helpers/withMiddleware";
import type { AvailabilityResponse } from "@lib/types";
import {
schemaAvailabilityEditBodyParams,
diff --git a/pages/api/users/index.ts b/pages/api/users/index.ts
index 28231b487ab..c07846423fa 100644
--- a/pages/api/users/index.ts
+++ b/pages/api/users/index.ts
@@ -1,68 +1,10 @@
-<<<<<<< HEAD
-import type { NextApiRequest, NextApiResponse } from "next";
-=======
import { defaultHandler } from "@calcom/lib/server";
->>>>>>> main
import { withMiddleware } from "@lib/helpers/withMiddleware";
-<<<<<<< HEAD
-/**
- * @swagger
- * /users:
- * get:
- * operationId: listUsers
- * summary: Find all users.
- * tags:
- * - users
- * responses:
- * 200:
- * description: OK
- * 401:
- * description: Authorization information is missing or invalid.
- * 404:
- * description: No users were found
- */
-async function getAllorCreateUser(
- { userId, method, body, prisma }: NextApiRequest,
- res: NextApiResponse<UsersResponse | UserResponse>
-) {
- const isAdmin = await isAdminGuard(userId);
- if (method === "GET") {
- if (!isAdmin) {
- // If user is not ADMIN, return only his data.
- const data = await prisma.user.findMany({ where: { id: userId } });
- const users = data.map((user) => schemaUserReadPublic.parse(user));
- if (users) res.status(200).json({ users });
- } else {
- // If user is admin, return all users.
- const data = await prisma.user.findMany({});
- const users = data.map((user) => schemaUserReadPublic.parse(user));
- if (users) res.status(200).json({ users });
- }
- } else if (method === "POST") {
- // If user is not ADMIN, return unauthorized.
- if (!isAdmin) res.status(401).json({ message: "You are not authorized" });
- else {
- const safeBody = schemaUserCreateBodyParams.safeParse(body);
- if (!safeBody.success) {
- res.status(400).json({ message: "Your body was invalid" });
- return;
- }
- const user = await prisma.user.create({
- data: safeBody.data,
- });
- res.status(201).json({ user });
- }
- }
-}
-
-export default withMiddleware("HTTP_GET_OR_POST")(getAllorCreateUser);
-=======
export default withMiddleware("HTTP_GET_OR_POST")(
defaultHandler({
GET: import("./_get"),
POST: import("./_post"),
})
);
->>>>>>> main