This repo exemplifies API rate limiting, using the token bucket algorithm.
the rate limitter implementation can be found in middlewares/rateLimiter/limitRate
- Allows for rate limit specification
- Allows for limit time range customisation
- provides hard throttling when rate limit exceeded
- Extendable
To run this project, you will need to add the following environment variables to your .env file if you choose to run locally
- Required
DATABASE_URL
=string
(databaseUrl)SECRET
=string
(Jwt secret)
-
How To:
- Automated test can be run using
yarn test
(this will require env variables) - The rate limiting functionality is tested by making recurrent request to the endpoints. It has been configured such that
the API allows a max of
10 requests
per client within a duration of1 mminute
. After 10 successful requests, Error429
is retuned. Also, the rate limit information is returned in the headers.
- Automated test can be run using
-
Local env test [ Downlad Postman Collection ]
-
Remote Ephemeral server test [ Downlad Postman Collection ]
- Downlad Postman Collection or click run in postman below
- make request to:
Note: the postman requests prepended with the "Local" keyword are to be used for local testing only
This File was generated by md-generator