diff --git a/src/app.ts b/src/app.ts index 546621b..6a26e6e 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,3 +1,6 @@ +import 'express-async-errors'; + +import { PrismaClient } from '@prisma/client'; import express, { json } from 'express'; import helmet from 'helmet'; @@ -5,12 +8,26 @@ const app = express(); app.use(json()); app.use(helmet()); +const prisma = new PrismaClient(); + app.get('/', (_, res) => { res.json({ msg: 'Hello World', }); }); +app.get('/prisma', async (_, res) => { + await prisma.user.create({ + data: { + email: 'random@example.com', + }, + }); + + res.json({ + msg: 'Add a new unique user without duplicate', + }); +}); + app.use((_, res, _2) => { res.status(404).json({ error: 'NOT FOUND' }); });