diff options
Diffstat (limited to 'examples/with-prisma/apps/web/pages/api/users.ts')
| -rw-r--r-- | examples/with-prisma/apps/web/pages/api/users.ts | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/examples/with-prisma/apps/web/pages/api/users.ts b/examples/with-prisma/apps/web/pages/api/users.ts deleted file mode 100644 index 3f7b3f0..0000000 --- a/examples/with-prisma/apps/web/pages/api/users.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { prisma } from "database"; - -import type { NextApiRequest, NextApiResponse } from "next"; - -/** - * Users - * - * @description A basic API endpoint to retrieve all the users in the database - */ -export default async function handler( - req: NextApiRequest, - res: NextApiResponse -) { - if (req.method !== "GET") { - res.setHeader("Allow", ["GET"]); - return res.status(405).end(`Method ${req.method} Not Allowed`); - } - - try { - const users = await prisma.user.findMany(); - if (!users) - throw { - message: "Failed to retrieve users", - status: 500, - }; - - return res.status(200).json({ - users, - }); - } catch ({ message = "An unknown error occured", status = 500 }) { - console.error({ message, status }); - return res.status(status).end(message); - } -} |
