aboutsummaryrefslogtreecommitdiff
path: root/src/app.ts
diff options
context:
space:
mode:
authorTom Harley2018-04-13 16:12:04 +0100
committerTom Harley2018-04-13 16:12:04 +0100
commit244fa29c38dcae5732a06cdb39de1a2a00557117 (patch)
tree5f280348fae84d974eb4adc769431a88e0b6273f /src/app.ts
parentMerge branch 'trh/gets' of gitlab.cs.st-andrews.ac.uk:cs3099group-be-4/projec... (diff)
downloadmedicine-244fa29c38dcae5732a06cdb39de1a2a00557117.tar.gz
medicine-244fa29c38dcae5732a06cdb39de1a2a00557117.zip

Fix minor places, and add Postman collection

Diffstat (limited to 'src/app.ts')
-rw-r--r--src/app.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/app.ts b/src/app.ts
index d8dfe5d..fd094ef 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -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: [
'/cs3099group-be-4/oauth/token',