2022-09-05 19:31:12 +00:00
|
|
|
import type { NextApiRequest } from "next";
|
|
|
|
|
2022-09-06 17:20:04 +00:00
|
|
|
import { defaultResponder } from "@calcom/lib/server";
|
2022-09-05 19:31:12 +00:00
|
|
|
|
2022-11-25 13:56:58 +00:00
|
|
|
import { schemaUserReadPublic } from "~/lib/validations/user";
|
2022-09-05 19:31:12 +00:00
|
|
|
|
2022-10-11 00:02:36 +00:00
|
|
|
async function handler({ userId, prisma }: NextApiRequest) {
|
2022-09-06 17:40:23 +00:00
|
|
|
const data = await prisma.user.findUniqueOrThrow({ where: { id: userId } });
|
2022-10-11 00:02:36 +00:00
|
|
|
return { user: schemaUserReadPublic.parse(data) };
|
2022-09-05 19:31:12 +00:00
|
|
|
}
|
|
|
|
|
2022-09-06 17:20:04 +00:00
|
|
|
export default defaultResponder(handler);
|