feat: add user management section

This commit is contained in:
Daniel Soares
2021-12-23 14:51:34 -03:00
parent f977de999d
commit 19aa8d2311
64 changed files with 1713 additions and 398 deletions

View File

@@ -0,0 +1,23 @@
import { prisma } from 'services/prisma'
import { ExceptionError } from 'utils/error'
import type { NextApiRequest, NextApiResponse } from 'next'
export async function getUserById(req: NextApiRequest, res: NextApiResponse) {
const { id } = req.params
const response = await prisma.user.findUnique({
where: { id: +id },
select: {
id: true,
username: true,
role: true
}
})
if (!response) {
throw new ExceptionError('No data found', 404)
}
res.status(200).json(response)
}