Storj Service Middleware
Common Express middleware for various Storj services.
$ npm install storj-service-middleware --save
var Storage = ;var db = /* config */ ;var middleware = ;var app = ; app;app;
Rate Limiter
Instantiate the rate limiter with a redis client client
and your express app app
const app = ;const client = ;const limiter = middleware;
Then, you can use limiter
as middleware and pass it an options object.
app;
Testing
Redis must be running for the tests to work. The easiest way to get an instance running is via Docker.
$ docker run --name redis -p 6379:6379 -d redis
Then, npm test
will kick off the test suite for you.
License
Credit for much of the rate limiter code goes to https://github.com/juliendangers/express-limiter2 released under the MIT license.
All other code released under AGPLv3.