Node RequestBuffer
An HTTP Request Buffer for Node.js
RequestBuffer enables late binding to the data
and end
events for HTTP requests.
The Problem
Binding to the standard data
and end
events in Node.js' http.ServerRequest
can get complicated once your application needs to perform an async call (such as authenticating a user) before processing an HTTP request body.
// ...;
The Solution
The simple solution is to always make sure you bind to the request events before any asynchronous functions are called. But passing the request 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.
RequestBuffer enables you to bind to the data event whenever you need without missing any data.
Example
var requestBuffer = ;// ...// Add the request buffer to the request object before any async callsserver;// ...;
Installation
npm install request-buffer