@belmonddev/catch-request-express-middleware 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +12 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -113,7 +113,7 @@ const callReceivedCbs = (req, res, requestReceivedCb) => {
113
113
  headers: req.headers,
114
114
  method: req.method,
115
115
  host: req.headers.host,
116
- pathname: req.url,
116
+ pathname: req._parsedUrl.pathname,
117
117
  params: req.params,
118
118
  query: req.query,
119
119
  body: req.body,
@@ -162,11 +162,18 @@ const catchExpressReceivedRequest = (req, res, requestReceivedCb) => {
162
162
  }
163
163
  };
164
164
 
165
- const catchRequestExpressMiddleware = (requestReceivedCb, requestSentCb) => {
166
- overrideHttpModule(http, requestSentCb);
167
- overrideHttpModule(https, requestSentCb);
165
+ const catchRequestExpressMiddleware = (
166
+ requestReceivedCb = null,
167
+ requestSentCb = null
168
+ ) => {
169
+ if (requestSentCb) {
170
+ overrideHttpModule(http, requestSentCb);
171
+ overrideHttpModule(https, requestSentCb);
172
+ }
168
173
  return (req, res, next) => {
169
- catchExpressReceivedRequest(req, res, requestReceivedCb);
174
+ if (requestReceivedCb) {
175
+ catchExpressReceivedRequest(req, res, requestReceivedCb);
176
+ }
170
177
  next();
171
178
  };
172
179
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@belmonddev/catch-request-express-middleware",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "start": "nodemon -L --experimental-specifier-resolution=node ./src/index.js"