-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.js
41 lines (29 loc) · 805 Bytes
/
router.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
const express = require('express');
const router = express.Router();
const ENV = require('./settings/env');
// router.get('/', (req, res)=>{
// res.send("Sever Up");
// })
module.exports = (app) => {
const env = new ENV();
app.get('/', (req, res, next)=>{
console.log(req.body);
})
// USER CONTROLLER
require('./controllers/UserController')(app);
// REPORT CONTROLLER
require('./controllers/ReportController')(app);
app.use((req, res, next)=>{
const error = new Error('Page Not Found');
error.status = 404;
next(error);
})
app.use((error, req, res, next)=>{
res.status(error.status || 5000);
res.json({
error: {
message: error.message
}
});
})
}