I have an Express-based Node.js application. I would like to convert line ending characters in my incoming request before the request passes to the rest of my Connect middleware stack (specifically, convert all LF characters to CRLF characters). Is there an existing Connect.js middleware for rewriting the request body? Ideally, I'd like to be able to do something like the following:
var rewriter = bodyRewriter(function(bodyString){
return bodyString.replace(/\n/g, "\r\n");
});
app.use(rewriter);
I've looked through this list of middleware but couldn't find anything that works. There's connect-modrewrite but it seems to work only for URLs, and not for request bodies; There's connect-injector but it only works for responses, not requests. I am very new to Node.js and would really like to avoid reinventing the wheel for this seemingly straightforward task... is there anything out there that I can use?