Me cleanup
parent
18e96e2a47
commit
a35454bb68
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue