response-time icon indicating copy to clipboard operation
response-time copied to clipboard

Add support for request-received middleware

Open niftylettuce opened this issue 6 years ago • 4 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 process.hrtime().

e.g. https://github.com/expressjs/response-time/blob/master/index.js#L53 would change from var startAt = process.hrtime() to var startAt = req[Symbol.for('request-received.startAt')] ? req[Symbol.for('request-received.startAt')] : process.hrtime()

niftylettuce avatar Jun 13 '19 22:06 niftylettuce

@dougwilson see #20

niftylettuce avatar Jun 13 '19 22:06 niftylettuce

Note that Symbol is not supported in v0.8 and v0.10, therefore I have changed engine and .travis.yml to support v0.12.0+

niftylettuce avatar Jun 13 '19 22:06 niftylettuce

Note that I am open to moving request-received to expressjs organization if need be.

niftylettuce avatar Jun 13 '19 23:06 niftylettuce

And/or if we could add these two Symbols internally to Express automatically?

niftylettuce avatar Jun 13 '19 23:06 niftylettuce