express-batching
v0.0.3
Published
A small higher order component for in-process batching and caching of API requests
Downloads
7
Maintainers
Readme
express-batching
A small higher order component for in-process batching and caching of API requests
Installation
$ npm install --save express-batching
Usage
const expressBatching = require('express-batching');
const app = require('express')();
const catRoutes = require('./catRoutes');
// normal
app.get('/cats', catRoutes.findAll);
// with batching
app.get('/cats', expressBatching(catRoutes.findAll));
// accepting a hash function for parameterized requests
app.get('/cats/:id', expressBatching(req => req.params.id, catRoutes.findOne));
Contributing
Contribute!
TODOs
In order of importance
- get a cool logo
- optimize perf
- config param
- cache timeout
- max queue size
- setter injection for alternative cache (redis)
- moar tests
Testing
mocha --require clarify lib/index.test.js --watch
License
Apache-2.0 © blugavere