1.0.7 • Published 4 years ago

custom-rate-limiter v1.0.7

Weekly downloads
13
License
MIT
Repository
github
Last release
4 years ago

SimpleRateLimiter

SimpleJSRateLimitersuper is a simple RateLimiter integrated with lru cache package.

const { RateLimiterSingleton } = require("custom-rate-limiter");

//SetRateLimitOptions(timelimit in milliseconds, maximumRequestInTimeLimit);
RateLimiterSingleton.SetRateLimitOptions(4000, 2);

//ThrowLimitExceptionIfNecessary('unique identifier for a specific user')
RateLimiterSingleton.GetInstance().ThrowLimitExceptionIfNecessary("2");
RateLimiterSingleton.GetInstance().ThrowLimitExceptionIfNecessary("3");

//should do nothing

////////////////////////////////////////////////////////////////////////////
RateLimiterSingleton.SetRateLimitOptions(4000, 2);
RateLimiterSingleton.GetInstance().ThrowLimitExceptionIfNecessary("2");
RateLimiterSingleton.GetInstance().ThrowLimitExceptionIfNecessary("2");
RateLimiterSingleton.GetInstance().ThrowLimitExceptionIfNecessary("2");

//should throw rate limit exception
1.0.2

4 years ago

1.0.1

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago