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