Deny clients exceeding 100 requests per second with isAllowed
You are tasked with safeguarding a web service or an API endpoint from potential abuse, such as denial-of-service (DOS) attacks, by implementing a rate limiter. Build a function called isAllowed within a RateLimiter class. This function should deny any request from a unique client that exceeds the threshold of 100 requests within the last second. For background on building a rate limiter in JavaScript, see this overview of rate limiting.
Consider the following examples to understand the functionality of the isAllowed function:
isAllowed should Allow this request.isAllowed should Deny any subsequent requests from Client B.isAllowed.This rate limiting mechanism serves as a defensive measure against excessive usage or attacks, ensuring that the web service remains available and performs optimally for all users.