Me cleanup

pull/9078/head
zomars 2022-10-10 18:02:36 -06:00
parent 18e96e2a47
commit a35454bb68
1 changed files with 2 additions and 12 deletions

View File

@ -4,19 +4,9 @@ import { defaultResponder } from "@calcom/lib/server";
import { schemaUserReadPublic } from "@lib/validations/user";
import { User } from ".prisma/client";
async function handler({
userId,
prisma,
}: NextApiRequest): Promise<{ error?: string; user?: Partial<User> }> {
async function handler({ userId, prisma }: NextApiRequest) {
const data = await prisma.user.findUniqueOrThrow({ where: { id: userId } });
if (!prisma) return { error: "Cant connect to database" };
if (!userId) return { error: "No user id found" };
if (!data) return { error: "You need to pass apiKey" };
const user = schemaUserReadPublic.parse(data);
return { user };
return { user: schemaUserReadPublic.parse(data) };
}
export default defaultResponder(handler);