-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
35 lines (29 loc) · 739 Bytes
/
app.js
File metadata and controls
35 lines (29 loc) · 739 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
const express = require("express");
const cors = require("cors");
const index = require("./routes/index");
const response = require("./utils/response");
class App {
constructor() {
this.app = express();
this.setMiddleWare();
this.getRouting();
this.errorHandler();
}
setMiddleWare() {
this.app.use(express.urlencoded({ extended: false }));
this.app.use(express.json());
this.app.use(cors());
}
getRouting() {
this.app.use("/", index);
}
errorHandler() {
this.app.use((req, res, _) => {
res.status(404).json(response.NOT_FOUND);
});
this.app.use((req, res, _) => {
res.status(500).json(response.INTERNAL_SERVER_ERROR);
});
}
}
module.exports = new App().app;