diff options
| author | Tom Harley | 2018-04-17 17:03:14 +0100 |
|---|---|---|
| committer | Tom Harley | 2018-04-17 17:03:14 +0100 |
| commit | 44c14c13bdd7ad91a119564622b811cc70147de8 (patch) | |
| tree | 318420a6bc570bcd3c990d387411e7a205a4e677 /src/app.ts | |
| parent | Merge branch 'trh/gets' of gitlab.cs.st-andrews.ac.uk:cs3099group-be-4/projec... (diff) | |
| parent | World War Files - changed precondition + filled addSubFileToFolder() function... (diff) | |
| download | medicine-44c14c13bdd7ad91a119564622b811cc70147de8.tar.gz medicine-44c14c13bdd7ad91a119564622b811cc70147de8.zip | |
Merge branch ‘trh/gets’ of gitlab.cs.st-andrews.ac.uk:cs3099group-be-4/project-code into trh/gets
Diffstat (limited to 'src/app.ts')
| -rw-r--r-- | src/app.ts | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -111,19 +111,22 @@ class App { important: 'Endpoints start from /cs3099group-be-4/' }); }); - const errRouter: ex.Router = ex.Router(); - errRouter.get('/*', (req: ex.Request, res: ex.Response): void => { - res.status(404) + this.express.use('/cs3099group-be-4', FileRouter); + this.express.use('/cs3099group-be-4', authRouter); + this.express.use('/', defRouter); + this.express.use((req: ex.Request, res: ex.Response, + next: ex.NextFunction): void => { + if (Object.keys(res.locals).length === 0) { + res.status(404) .json({ status: 'error', error : 'invalid_route', error_description: 'Endpoints start from /cs3099group-be-4/' }); + } else { + next(); + } }); - this.express.use('/cs3099group-be-4', FileRouter); - this.express.use('/cs3099group-be-4', authRouter); - this.express.use('/', defRouter); - this.express.use('/XX*', errRouter); } /** @@ -142,5 +145,5 @@ export default new App(true).express; */ // tslint:disable-next-line:variable-name export const TestApp: () => ex.Express = (): ex.Express => { - return new App(false).express; + return new App(true).express; }; |
