Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 406aa99

Browse files
author
Michal Vlasák
committed
Fix request skipping
1 parent 7210d8f commit 406aa99

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/express.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ const expressOnFinished = (logger: AckeeLogger, req: AckeeRequest) => (_err: Err
2727
const error = res[errorSymbol];
2828
const userAgent = req.headers['user-agent'];
2929
const reqOut = `${res.statusCode} ${req.method} ${req.originalUrl} ${res.time} ms ${userAgent ? userAgent : ''}`;
30-
if (logger.options.ignoredHttpMethods && logger.options.ignoredHttpMethods.includes(req.method)) {
31-
// left here for BC
32-
return;
33-
}
34-
if (logger.options.skip && logger.options.skip(req)) {
35-
return;
36-
}
3730
const standardOutput = {
3831
data: {
3932
req,
@@ -60,7 +53,14 @@ const expressMiddleware: RequestHandler = function(
6053
) {
6154
const userAgent = req.headers['user-agent'];
6255
const reqIn = `--- ${req.method} ${req.originalUrl} ${userAgent ? userAgent : ''}`;
63-
this.debug({ req, ackId: req.ackId }, `${reqIn} - Request accepted`);
56+
if (this.options.ignoredHttpMethods && this.options.ignoredHttpMethods.includes(req.method)) {
57+
// entire method skipped - left here for BC
58+
return next();
59+
}
60+
if (!this.options.skip || !this.options.skip(req)) {
61+
// if request not skipped
62+
this.debug({ req, ackId: req.ackId }, `${reqIn} - Request accepted`);
63+
}
6464
req._startAt = process.hrtime();
6565
onHeaders(response, expressOnHeaders(req, response));
6666
onFinished(response, expressOnFinished(this, req));

0 commit comments

Comments
 (0)