diff options
| author | jw255 | 2018-04-13 16:26:49 +0100 |
|---|---|---|
| committer | jw255 | 2018-04-13 16:26:49 +0100 |
| commit | 2f89017a5f6cca3077936432b6e5b35167fc8e0d (patch) | |
| tree | 4d6a9306513b4cfafece1f3ed2f562999b8451ad /src/app.ts | |
| parent | fixed privileges in testing database (diff) | |
| parent | Merge branch 'trh/gets' of gitlab.cs.st-andrews.ac.uk:cs3099group-be-4/projec... (diff) | |
| download | medicine-2f89017a5f6cca3077936432b6e5b35167fc8e0d.tar.gz medicine-2f89017a5f6cca3077936432b6e5b35167fc8e0d.zip | |
Merge branch ‘trh/gets’ of https://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 | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -4,6 +4,7 @@ import * as expressJwt from 'express-jwt'; import * as passport from 'passport'; import { default as authRouter, unauthorisedErr } from './auth'; +import { logger } from './logger'; import { RequestError, errorHandler } from './errors/errorware'; import FileRouter from './FileRouter'; @@ -39,11 +40,15 @@ class App { * server. */ public constructor(enableLog: boolean) { + logger.debug('Constructing router'); this.logEnabled = enableLog; this.express = ex(); - this.express.use(( - req: ex.Request, res: ex.Response, next: ex.NextFunction - ): void => { console.log(req.url); next(); }); + this.express.use( + (req: ex.Request, res: ex.Response, next: ex.NextFunction): void => { + logger.info(`Connection from ${req.ip} requesting ${req.url}`); + next(); + } + ); this.middleware(); this.mountRoutes(); this.express.use( @@ -57,6 +62,7 @@ class App { data: await res.locals.data }); } + logger.success(`Responded to ${req.ip}`); } ); this.errorware(); @@ -66,6 +72,7 @@ class App { * Configures regular Express middleware. */ private middleware(): void { + logger.debug('Loading basic middleware'); this.express.use(expressJwt({secret: 'Mr Secret'}) .unless({path: [ '/', |
