fix: prisma not defined
This commit is contained in:
@@ -6,11 +6,14 @@ import { schemaUserReadPublic } from "@lib/validations/user";
|
||||
|
||||
import { User } from ".prisma/client";
|
||||
|
||||
async function handler(req: NextApiRequest): Promise<{ error?: string; user?: Partial<User> }> {
|
||||
async function handler({
|
||||
userId,
|
||||
prisma,
|
||||
}: NextApiRequest): Promise<{ error?: string; user?: Partial<User> }> {
|
||||
const data = await prisma.user.findUniqueOrThrow({ where: { id: userId } });
|
||||
if (!prisma) return { error: "Cant connect to database" };
|
||||
console.log(req);
|
||||
if (!req.userId) return { error: "No user id found" };
|
||||
const data = await prisma.user.findUniqueOrThrow({ where: { id: req.userId } });
|
||||
|
||||
if (!userId) return { error: "No user id found" };
|
||||
if (!data) return { error: "You need to pass apiKey" };
|
||||
const user = schemaUserReadPublic.parse(data);
|
||||
return { user };
|
||||
|
||||
Reference in New Issue
Block a user