-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (29 loc) · 883 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
30
31
32
33
34
35
const app = require("./server")
const requestParser = require("./server/pipeline/requestParser")
const cookieParser = require("./server/pipeline/cookieParser")
const bodyParser = require("./server/pipeline/bodyParser")
const staticHandler = require("./server/pipeline/staticHandler")
const { router, routeHandler } = require("./server/pipeline/routeHandler")
const {
getTodos,
getTodo,
postTodo,
updateTodo,
deleteTodo,
uploadFile,
} = require("./controllers")
const port = 3030
app
.passThrough(requestParser)
.passThrough(cookieParser)
.passThrough(bodyParser)
.passThrough(staticHandler)
.passThrough(routeHandler)
.start()
router.get("/todos", getTodos)
router.get("/todos/:id", getTodo)
router.post("/todos", postTodo)
router.put("/todos/:id", updateTodo)
router.delete("/todos/:id", deleteTodo)
router.post("/upload", uploadFile)
app.listen(port)