compression
compression copied to clipboard
Move the res.write interception into a separate repo
It needs to be in it's own repo so it can be well-tested and not need tests polluting this library.
Love this move.
So just if you were wondering, @aredridel , the idea is to provide a through stream-like interface as well as a buffered-up interface, not only for use in this library, but for use to do things like re-write links in HTML responses. It would also take care of altering the headers like Content-Length
for you so they are actually correct.
That sounds like my use cases! Security hacks, link rewrites, compression, verification trailers, all kinds of uses.
All very important uses indeed. The main reason this alters a res
is for compatibility with the middleware pattern as well as avoiding the complications of needing to re-implement core functionality or needing to jump through hoops to delegate correctly. This stuff that is coming is extremely well tested and builds off the current Node.js core expertise :)
Can't happen soon enough. Another use case: output validation. Any sort of tentative timeline?
Any sort of tentative timeline?
Just time-dependent. It's also not easy to get right; there are so many edge cases. I also need it very much :)
Any updates on this? I need this for a bandwidth monitoring middleware I'm working on. For now, I resorted to copy-pasting the code from here :/
I've started working on something for my own middleware: https://github.com/strongloop/express/issues/2811#issuecomment-158633664
Would be nice to see if it works with this module. Eventually we could extract the patch(res)
procedure to a standalone middleware that needs to be used before response transform stream middlewares like this one. e.g.:
import responseUse from 'response-use';
app.use(responseUse);
app.use(compression);
The compression module could add itself to the list of transform stream with res.use(compressionStream)
instead of having to patch res.write/res.end.
Let me know your thoughts.
Created a repo here: https://github.com/olalonde/express-transform