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

20 lines
530 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";
import type { NextApiRequest, NextApiResponse } from "next";
type ResponseData = {
data?: User[];
error?: unknown;
};
export default async function user(req: NextApiRequest, res: NextApiResponse<ResponseData>) {
try {
const users = await prisma.user.findMany();
res.status(200).json({ data: { ...users } });
} catch (error) {
// FIXME: Add zod for validation/error handling
res.status(400).json({ error: error });
}
}