-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
56 lines (48 loc) · 1.06 KB
/
app.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
//Importing Express.js module
const express = require("express");
//Importing BodyParser.js module
const bodyParser = require("body-parser");
/**
* Class Definition for the REST API
*/
class BlockAPI {
/**
* Constructor that allows initialize the class
*/
constructor() {
this.app = express();
this.initExpress();
this.initExpressMiddleWare();
this.initControllers();
this.start();
}
/**
* Initialization of the Express framework
*/
initExpress() {
this.app.set("port", 8000);
}
/**
* Initialization of the middleware modules
*/
initExpressMiddleWare() {
this.app.use(bodyParser.urlencoded({extended:true}));
this.app.use(bodyParser.json());
}
/**
* Initilization of all the controllers
*/
initControllers() {
require("./BlockController.js")(this.app);
}
/**
* Starting the REST Api application
*/
start() {
let self = this;
this.app.listen(this.app.get("port"), () => {
console.log(`Server Listening for port: ${self.app.get("port")}`);
});
}
}
new BlockAPI();