onedionys-api-rate-limiting-handler

5.0.0 • Public • Published

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

Package Sidebar

Install

npm i onedionys-api-rate-limiting-handler

Weekly Downloads

5

Version

5.0.0

License

ISC

Unpacked Size

13.2 kB

Total Files

6

Last publish

Collaborators

  • onedionys