aboutsummaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
Diffstat (limited to 'dist')
-rw-r--r--dist/app.js9
-rw-r--r--dist/index.js5
2 files changed, 12 insertions, 2 deletions
diff --git a/dist/app.js b/dist/app.js
index 7e34ef9..e983ca8 100644
--- a/dist/app.js
+++ b/dist/app.js
@@ -1,11 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const express = require("express");
+const logger = require("morgan");
+const bodyParser = require("body-parser");
class App {
constructor() {
this.express = express();
+ this.middleware();
this.mountRoutes();
}
+ // Configure Express middleware.
+ middleware() {
+ this.express.use(logger('combined'));
+ this.express.use(bodyParser.json());
+ this.express.use(bodyParser.urlencoded({ extended: false }));
+ }
mountRoutes() {
const router = express.Router();
router.get('/', (req, res) => {
diff --git a/dist/index.js b/dist/index.js
index 9392034..7628251 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1,11 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-console.log('Hello, TypeScript!');
+console.log('Welcome to the CS3099 Server thingy!');
const app_1 = require("./app");
+// use default port 3000 or port supplied by OS
const port = process.env.PORT || 3000;
app_1.default.listen(port, (err) => {
if (err) {
return console.log(err);
}
- return console.log(`server is listening on ${port}`);
+ return console.log(`server is listening on port ${port}`);
});