-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
45 lines (36 loc) · 972 Bytes
/
index.ts
File metadata and controls
45 lines (36 loc) · 972 Bytes
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import express from 'express'
import { prisma } from './prisma';
import { z } from 'zod'
const PORT = 4000
const app = express();
app.use(express.json());
app.get("/bigas", async (req, res) => {
const examples = await prisma.example.findMany()
return res.json({
message: "Bigas é um bokinha dedo no cu e gritaria () => {}",
examples
})
})
app.post("/bigas", async (req, res) => {
const result = z.object({
name: z.string().min(1),
description: z.string().min(1)
}).safeParse(req.body)
if (!result.success) {
console.log(result.error);
return res.status(400).json({
message: "VC EH BUIRRO"
})
}
const created = await prisma.example.create({
data: {
name: result.data.name,
description: result.data.description
}
})
return res.json({
message: "Bigas criado",
created
})
})
app.listen(PORT, () => console.log(`Listening on ${PORT}`))