Open magicmark opened 6 years ago
(Shoving arbitrary things on the request object is clearly not ideal. I still need to do some more thinking here, but that's probably an orthogonal problem)
I usually stick things on the response object (and never mutate the request)
Oh that sounds better, yea! @ljharb++
ok so same question, s/request/response/ ?
Why don't we pass a reference to res.locals
?
Ah yeah, even better I suppose.
I'll update my PR. Thanks for the quick responses!
Hi @goatslacker!
So I have a logger set up inside an express middleware, logging various things about the request.
One bit of information I'd like to add to the logs is - did the request hit a cold cache or not?
I have access to this information inside of my application code - inside of
getComponent
. However there's no great way that I can currently think of to thread this information along to other parts of the express app.I'm thinking one way to do this would be to expose the express
request
object to the context object passed intogetComponent
https://github.com/airbnb/hypernova/blob/477257daad82e04f24ce851a9b3d21625354c783/src/utils/BatchManager.js#L90Or maybe there's just a better way to architect this?
Thanks!