chore: no default export
This commit is contained in:
1 parent
75e635cb37
commit
3011e0ecf7
9 files changed
+29
-19
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
import prisma from "@calcom/prisma";
|
||||
import { withMiddleware } from "@lib/helpers/withMiddleware";
|
||||
import { schemaQueryIdParseInt, withValidQueryIdTransformParseInt } from "@lib/validations/shared/queryIdTransformParseInt";
|
||||
|
||||
|
||||
@@ -24,4 +25,4 @@ export async function deleteUser(req: NextApiRequest, res: NextApiResponse<Respo
|
||||
} else res.status(405).json({ message: "Only DELETE Method allowed" });
|
||||
}
|
||||
|
||||
export default withValidQueryIdTransformParseInt(deleteUser);
|
||||
export default withMiddleware("addRequestId")((withValidQueryIdTransformParseInt(deleteUser)));
|
||||
@@ -4,6 +4,7 @@ import { User } from "@calcom/prisma/client";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
import { schemaUser, withValidUser } from "@lib/validations/user";
|
||||
import { withMiddleware } from "@lib/helpers/withMiddleware";
|
||||
import { schemaQueryIdParseInt, withValidQueryIdTransformParseInt } from "@lib/validations/shared/queryIdTransformParseInt";
|
||||
|
||||
type ResponseData = {
|
||||
@@ -29,4 +30,4 @@ export async function editUser(req: NextApiRequest, res: NextApiResponse<Respons
|
||||
} else res.status(405).json({ message: "Only PATCH Method allowed for updating users" });
|
||||
}
|
||||
|
||||
export default withValidQueryIdTransformParseInt(withValidUser(editUser));
|
||||
export default withMiddleware("addRequestId")(withValidQueryIdTransformParseInt(withValidUser(editUser)));
|
||||
@@ -4,6 +4,7 @@ import { User } from "@calcom/prisma/client";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
import { schemaQueryIdParseInt, withValidQueryIdTransformParseInt } from "@lib/validations/shared/queryIdTransformParseInt";
|
||||
import { withMiddleware } from "@lib/helpers/withMiddleware";
|
||||
|
||||
type ResponseData = {
|
||||
data?: User;
|
||||
@@ -24,4 +25,4 @@ export async function user(req: NextApiRequest, res: NextApiResponse<ResponseDat
|
||||
}
|
||||
|
||||
|
||||
export default withValidQueryIdTransformParseInt(user);
|
||||
export default withMiddleware("addRequestId")(withValidQueryIdTransformParseInt(user));
|
||||
@@ -1,7 +1,7 @@
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
import { User } from "@calcom/prisma/client";
|
||||
import withMiddleware from "@lib/helpers/withMiddleware";
|
||||
import { withMiddleware } from "@lib/helpers/withMiddleware";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
type ResponseData = {
|
||||
@@ -14,4 +14,5 @@ async function user(req: NextApiRequest, res: NextApiResponse<ResponseData>) {
|
||||
if (data) res.status(200).json({ data });
|
||||
else res.status(400).json({ error: "No data found" });
|
||||
}
|
||||
|
||||
export default withMiddleware("addRequestId")(user);
|
||||
+12
-12
@@ -1,26 +1,26 @@
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
import { User } from "@calcom/prisma/client";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
import prisma from "@calcom/prisma";
|
||||
import { User } from "@calcom/prisma/client";
|
||||
import { withMiddleware } from "@lib/helpers/withMiddleware";
|
||||
import { schemaUser, withValidUser } from "@lib/validations/user";
|
||||
|
||||
|
||||
type ResponseData = {
|
||||
data?: User;
|
||||
message?: string;
|
||||
error?: string;
|
||||
error?: object;
|
||||
};
|
||||
|
||||
async function createUser(req: NextApiRequest, res: NextApiResponse<ResponseData>) {
|
||||
const { body, method } = req;
|
||||
const safe = schemaUser.safeParse(body);
|
||||
if (method === "POST" && safe.success) {
|
||||
await prisma.user
|
||||
.create({ data: safe.data })
|
||||
.then((data) => res.status(201).json({ data }))
|
||||
.catch((error) => res.status(400).json({ message: "Could not create user type", error: error }));
|
||||
// Reject any other HTTP method than POST
|
||||
} else res.status(405).json({ error: "Only POST Method allowed" });
|
||||
const data = await prisma.user
|
||||
.create({ data: safe.data })
|
||||
if (data) res.status(201).json({ data })
|
||||
else (error: unknown) => res.status(400).json({ error: { message: "Could not create user type", error: error } });
|
||||
// Reject any other HTTP method than POST
|
||||
} else res.status(405).json({ error: { message: "Only POST Method allowed" } });
|
||||
}
|
||||
|
||||
export default withValidUser(createUser);
|
||||
export default withMiddleware("addRequestId")(withValidUser(createUser));
|
||||
Reference in new issue
Block a user