Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the res.write interception into a separate repo #13

Open
dougwilson opened this issue Jun 4, 2014 · 9 comments
Open

Move the res.write interception into a separate repo #13

dougwilson opened this issue Jun 4, 2014 · 9 comments
Assignees
Labels

Comments

@dougwilson
Copy link
Contributor

It needs to be in it's own repo so it can be well-tested and not need tests polluting this library.

@aredridel
Copy link

Love this move.

@dougwilson
Copy link
Contributor Author

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.

@aredridel
Copy link

That sounds like my use cases! Security hacks, link rewrites, compression, verification trailers, all kinds of uses.

@dougwilson
Copy link
Contributor Author

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 :)

@tlivings
Copy link

Can't happen soon enough. Another use case: output validation. Any sort of tentative timeline?

@dougwilson
Copy link
Contributor Author

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 :)

@olalonde
Copy link

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 :/

@olalonde
Copy link

I've started working on something for my own middleware: expressjs/express#2811 (comment)

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.

@olalonde
Copy link

Created a repo here: https://github.com/olalonde/express-transform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants