aboutsummaryrefslogtreecommitdiff
path: root/src/app.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.ts')
-rw-r--r--src/app.ts55
1 files changed, 27 insertions, 28 deletions
diff --git a/src/app.ts b/src/app.ts
index 83bf2b0..c81be8a 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -1,37 +1,36 @@
-import * as express from 'express';
-import * as logger from 'morgan';
import * as bodyParser from 'body-parser';
+import * as ex from 'express';
import FileRouter from './FileRouter';
-
+import * as logger from 'morgan';
class App {
- public express
+ public express: ex.Express;
- constructor () {
- this.express = express()
- this.middleware()
- this.mountRoutes()
- }
+ public constructor() {
+ this.express = ex();
+ this.middleware();
+ this.mountRoutes();
+ }
- // Configure Express middleware.
- private middleware(): void {
- this.express.use(logger('combined'));
- this.express.use(bodyParser.json());
- this.express.use(bodyParser.urlencoded({ extended: false }));
- }
+ // Configure Express middleware.
+ private middleware(): void {
+ this.express.use(logger('combined'));
+ this.express.use(bodyParser.json());
+ this.express.use(bodyParser.urlencoded({ extended: false }));
+ }
- // Configure API endpoints.
- private mountRoutes (): void {
- const defRouter = express.Router()
- defRouter.get('/', (req, res) => {
- res.json({
- message: 'Welcome to the CS3099 BE4 server!',
- important : 'Endpoints start from /cs3099group-be-4/'
- })
- })
- this.express.use('/', defRouter)
- this.express.use('/cs3099group-be-4', FileRouter)
- }
+ // Configure API endpoints.
+ private mountRoutes(): void {
+ const defRouter: ex.Router = ex.Router();
+ defRouter.get('/', (req: ex.Request, res: ex.Response): void => {
+ res.json({
+ message: 'Welcome to the CS3099 BE4 server!',
+ important : 'Endpoints start from /cs3099group-be-4/'
+ });
+ });
+ this.express.use('/', defRouter);
+ this.express.use('/cs3099group-be-4', FileRouter);
+ }
}
-export default new App().express
+export default new App().express;