-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (25 loc) · 844 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import express from 'express'
import { PrismaClient } from '@prisma/client'
import dotenv from 'dotenv'
const app = express()
app.use(express.json())
dotenv.config();
const prisma = new PrismaClient();
app.get('/', async (req, res) => {
res.send("Server is Running");
})
app.post('/user', async (req, res) => {
const { email, mood } = req.body
const post = await prisma.User.create({
data: { email:email, mood:mood, },
})
res.json(post)
})
app.get('/user', async (req, res) => {
const post = await prisma.User.findMany({})
res.json(post)
})
const port= process.env.PORT;
app.listen(port,()=>console.log("Listen to `${port}`"))
/* Prisma AutoComplete or Intellisense fix
-https://stackoverflow.com/questions/72102079/single-instance-prisma-client-autocomplete-not-working */