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