mirror of
https://github.com/dsoaress/link-free.git
synced 2026-11-18 02:08:34 +00:00
21 lines
459 B
TypeScript
21 lines
459 B
TypeScript
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)
|
|
}
|