pino-http icon indicating copy to clipboard operation
pino-http copied to clipboard

Add support for request-received middleware

Open niftylettuce opened this issue 5 years ago • 1 comments

The request-received middleware at https://github.com/cabinjs/request-received exposes a Symbol.for property, which this package could conditionally consume if interested (as opposed to just generating a new Date().

e.g. https://github.com/pinojs/pino-http/blob/master/logger.js#L63 would change as follows:

-    res[startTime] = res[startTime] || Date.now()
+    res[startTime] = res[startTime] || req[Symbol.for('request-received.startTime')] ? req[Symbol.for('request-received.startTime')].getTime() : Date.now()

Ref: #65

niftylettuce avatar Jun 13 '19 22:06 niftylettuce

PR #67 opened

niftylettuce avatar Jun 13 '19 22:06 niftylettuce