async function getUserById(req: Request, res: Response) {
const userId = parseInt(req.params.id);
try {
const user = await prisma.user.findUniqueOrThrow({
where: {
id: userId,
},
});
res.status(200).json(user);
} catch (error: Prisma.PrismaClientKnownRequestError) {
res.status(404).json({ message: error.meta });
}
}
async function getUserById(req: Request, res: Response) {
const userId = parseInt(req.params.id);
try {
const user = await prisma.user.findUniqueOrThrow({
where: {
id: userId,
},
});
res.status(200).json(user);
} catch (error: Prisma.PrismaClientKnownRequestError) {
res.status(404).json({ message: error.meta });
}
}