-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (31 loc) · 855 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
36
const express = require('express');
const bodyParser = require('body-parser');
const methodOverride = require('method-override');
const { router } = require('./router');
const app = express();
const port = 3000;
class Server {
static bootstrap() {
return new Server();
}
constructor() {
this.configureApp();
this.configureServer();
}
configureApp() {
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(methodOverride());
app.use('/', router);
}
async configureServer() {
try {
app.listen(port, () =>
console.log(`server started on port ${port}`)
);
} catch (error) {
console.log('Unable to start server', error);
}
}
}
exports = Server.bootstrap();