2020-04-22 15:52:17 +02:00
|
|
|
import ApplicationComponent from "../ApplicationComponent";
|
|
|
|
import onFinished from "on-finished";
|
|
|
|
import Logger from "../Logger";
|
|
|
|
import {Express, Router} from "express";
|
|
|
|
|
|
|
|
export default class LogRequestsComponent extends ApplicationComponent<void> {
|
|
|
|
public async start(app: Express, router: Router): Promise<void> {
|
|
|
|
router.use((req, res, next) => {
|
|
|
|
onFinished(res, (err) => {
|
|
|
|
if (!err) {
|
2020-06-04 10:15:24 +02:00
|
|
|
Logger.info(`${req.method} ${req.originalUrl} Accept: ${req.accepts()} - ${res.statusCode}`);
|
2020-04-22 15:52:17 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public async stop(): Promise<void> {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|