A simple custom implementation of a token bucket based rate limiter in Node.js and TypeScript for practice.
- Add key based rate limiting (ip, user, etc)
- Support distributed rate limiting using Redis
- Add implementations of other common algorithms: leaky bucket, sliding window counter, etc.
Install dependencies
npm install
Set up .env
file
PORT=8080
Run in development mode
npm run dev
Call endpoint protected with Rate Limiter
curl localhost:8080
Run unit and end to end tests using Jest
npm run test