cal.pub0.org/pages/api/users/index.ts

19 lines
569 B
TypeScript
Raw Normal View History

import prisma from "@calcom/prisma";
2022-03-26 04:28:53 +00:00
import { User } from "@calcom/prisma/client";
2022-03-29 01:23:22 +00:00
import { withMiddleware } from "@lib/helpers/withMiddleware";
2022-03-26 04:28:53 +00:00
import type { NextApiRequest, NextApiResponse } from "next";
type ResponseData = {
data?: User[];
error?: unknown;
};
async function allUsers(req: NextApiRequest, res: NextApiResponse<ResponseData>) {
const data = await prisma.user.findMany();
if (data) res.status(200).json({ data });
else res.status(400).json({ error: "No data found" });
}
2022-03-29 01:23:22 +00:00
export default withMiddleware("addRequestId","getOnly")(allUsers);