-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
61 lines (43 loc) · 1.31 KB
/
server.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const { initServer, initDB } = require("./init");
const { server, router } = initServer();
const db = initDB();
const { routing } = require('./routing');
routing(server, db, router);
server.listen(3080, () => console.log("SERVER is running on port 3080"));
// const router = jsonServer.router("db.json");
// const middlewares = jsonServer.defaults({
// noCors: true
// });
// const { anonymous, auth } = require("./middlewares");
// anonymous(server);
// // auth(server);
// server.use(middlewares);
// server.use(jsonServer.bodyParser);
// server.post("/login", (req, res, next) => {
// req.url = `/users?email=${req.body.email}`;
// req.method = 'get';
// console.log(req.url);
// server._router.handle(req, res, next);
// // res.json({
// // status: {
// // code: 200,
// // userToken: 1
// // }
// // });
// });
// // server.get('/users', (req, res, next) => {
// // res.json(req.params);
// // })
// server.post("/lala", (req, res) => {
// res.json({
// reqHeaders: req.header("authorization"),
// reqBody: req.body,
// reqParams: req.query,
// reqUrl: req.path
// });
// });
// server.post("/categories", (req, res, next) => {
// next();
// });
// server.use(router);
// server.listen(3080, () => console.log("SERVER is running on port 3080"));