npm.io
5.0.0 • Published 2 years ago

onedionys-api-rate-limiting-handler

Licence
ISC
Version
5.0.0
Deps
132
Size
13 kB
Vulns
0
Weekly
0
Stars
3

Welcome to One Dionys - API Rate Limiting Handler!

Functions to manage rate limiting when interacting with APIs, prevent abuse and ensure service availability.

Requirements

  • Web Browser - Can be used as an emulator to build applications. Example [Chrome, Firefox, Safari & Opera].
  • Internet - Because many use CDN and to make it easier to find solutions to all problems.

How To Use

Example Syntax
const RateLimitHandler = require('./src/rateLimitHandler');

// Create a new rate limiter with a limit of 5 requests per minute
const rateLimiter = new RateLimitHandler(5, 60000);

// Handle incoming requests
if (rateLimiter.handleRequest()) {
  // Allow the request to proceed
  console.log('Request allowed');
} else {
  // Block the request
  console.log('Request blocked due to rate limiting');
}
Explanation
  • This package provides a simple rate limiting handler for APIs. The RateLimitHandler class takes two parameters: limit, which specifies the maximum number of requests allowed within the given interval (in milliseconds). The handleRequest method is used to check whether a request should be allowed based on the current rate limit.
Return Value
  • true: If the request is allowed within the rate limit.
  • false: If the request exceeds the rate limit and should be blocked.

Release Date

  • v1.0.0 : 17 March 2024
  • v1.0.1 : 18 March 2024
  • v1.0.2 : 20 March 2024
  • v5.0.0 : 31 March 2024

Author

License

  • Copyright 2024 One Dionys
  • One Dionys - API Rate Limiting Handler is an open source project licensed under the MIT license

Suppport & Donation

Love One Dionys - API Rate Limiting Handler? Support this project by donating or sharing with others in need.

Made with One Dionys

Keywords