express-rate-limit-middleware
Installation |
Usage |
Options |
License
Limiting access to endpoint using express middleware backed by LevelDB like and redis storage
Installation
npm install --save express-rate-limit-middleware
Usage
- By default, you only need to pass 2 parameters, limit and reset
- You can use this middleware as application level (every endpoint will be limited) or router level
- Application Level Middleware
const express = const app = const rateLimiter = rateLimit // limit 1000 request per hour to all urlapp
- Router Level Middleware
const express = const router = expressconst rateLimiter = rateLimit // limit 1000 request per hour to all urlrouter
Options
- limit : How many request per interval
- reset : Interval
- storageEngine : Storage engine you want to use, we provide 2 storage engine, levelDB and redis. LevelDB storage will be used if you don't pass this parameter
- Example of using redis
const express = const app = const redisStorage = redisRateLimitconst redisClient = host: '127.0.0.1' port: 6379 options: db: 1 // here i'm using redis-pool-connection module but you can use any redis clientconst rateLimiter = rateLimitappapp// Middlewares setupappappappapp
Todo
- Key generator parameter
- Logging
- Redis storage plugin
License
MIT © [Adhitya Ramadhanus]