An HTTP Request Buffer for Node.js

Node RequestBuffer

RequestBuffer enables simple late binding to the 'data' event for HTTP requests.

Binding to the standard data and end events in Node.js' http.ServerRequest work in many situations. But as your application expands you'll often find that you need to call some asynchronous functions before you begin to work with the request body.

// ... 
authenticateUser(function(authed) {
  if(authed) {
    request.on('data', function(chunk) {
      // It may be too late to bind at this point 

The simple solution is to always make sure you bind to the request events before any asynchronous functions are called. But passing the event data around and handling it properly can be difficult, especially when using a framework where the request data may need to be passed around by several methods.

This is where RequestBuffer comes in handy. RequestBuffer enables you to bind to the data event whenever you need without missing any data.

TODO: Sample Code

TODO: Installation