Files
link-free/src/api/users/getUsers.ts
T

20 lines
459 B
TypeScript
Raw Normal View History

2021-12-23 14:51:34 -03:00
import { prisma } from 'services/prisma'
import { ExceptionError } from 'utils/error'
import type { NextApiRequest, NextApiResponse } from 'next'
export async function getUsers(_req: NextApiRequest, res: NextApiResponse) {
const response = await prisma.user.findMany({
select: {
id: true,
username: true,
role: true
}
})
if (!response) {
throw new ExceptionError('No data found')
}
res.status(200).json(response)
}