
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
batch-request-patch
Advanced tools
Batch Request - Utility library to enable a server to handle batch requests and typescript friendly
Batch Request is lightweight connect/express middleware for Node.js which allows clients to send multiple requests to a server running Node.js in batch. This library is derived from batch request. Due to project needs, I need to further process data after batch response. Therefore I patched it to fulfill following needs:
Looking for the Koa version of this module?
Before you use this library, please keep in mind that you have used body-parser as one of your middlewares (express.bodyParser() or express.json() is needed). The official batch request documentation is somehow did not document it. However, it is mentioned in its source code batch-request/lib/batch-request.js line 48.
If you desire to use Typescript, just type tsd link in your command.
You can do as followings:
var batch = require('batch-request-patch')();
// Javascript/Typescript way. Simple case.
app.post('/batch', batch);
Optionally included 'batch.validate' middleware to check the validity of your batch request, as well as further process return data as you need:
// Include the batch.validate middleware before batch middleware
app.post('/batch', batch.validate, batch, (req,res)=>{
// proxy return data will be passed into the req.batch object
console.log(req.batch);
});
//Typescript way. Recommended to write in this way:
batchRouter.post('/batch', batch.validate, batch, (req: IBatchRequest, res: express.Response)=> {
//do whatever you want wih req.batch
res.json(req.batch);
});
FAQs
Batch Request - Utility library to enable a server to handle batch requests and typescript friendly
We found that batch-request-patch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.