diff options
| author | THarley | 2018-02-22 17:20:56 +0000 |
|---|---|---|
| committer | THarley | 2018-02-22 17:20:56 +0000 |
| commit | 0d917ec729ea8a54ae340033a3c95cc48f3cf6ea (patch) | |
| tree | b2dbed468410c5f1f7905775ed627c4b4aa4851b /src/app.ts | |
| parent | Merge branch 'trh/yarn' into trh/payload-checker (diff) | |
| parent | Include error-handling in middleware stack (diff) | |
| download | medicine-0d917ec729ea8a54ae340033a3c95cc48f3cf6ea.tar.gz medicine-0d917ec729ea8a54ae340033a3c95cc48f3cf6ea.zip | |
Merge branch ‘trh/error-middleware’ into ‘trh/payload-checker’
Error-handling Middleware
See merge request cs3099group-be-4/project-code!14
Diffstat (limited to 'src/app.ts')
| -rw-r--r-- | src/app.ts | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1,8 +1,10 @@ import * as bodyParser from 'body-parser'; import * as ex from 'express'; -import FileRouter from './FileRouter'; import * as logger from 'morgan'; +import { errorHandler } from './errors/errorware'; +import FileRouter from './FileRouter'; + class App { public express: ex.Express; public logEnabled: boolean = true; @@ -11,6 +13,7 @@ class App { this.express = ex(); this.middleware(); this.mountRoutes(); + this.errorware(); } // Configure Express middleware. @@ -34,6 +37,10 @@ class App { this.express.use('/', defRouter); this.express.use('/cs3099group-be-4', FileRouter); } + + private errorware(): void { + this.express.use(errorHandler); + } } export default new App().express; |
