{"repo":"microlinkhq/async-ratelimiter","free":true,"listed":false,"github":"https://github.com/microlinkhq/async-ratelimiter","clone":"git clone https://github.com/microlinkhq/async-ratelimiter.git","description":"Simple async rate limiter for Node.js — promise-friendly limits for APIs and workers.","language":"JavaScript","stars":335,"topics":["api","async","concurrency","limiter","promise","rate-limit","ratelimiter","redis","throttle","token-bucket"],"license":"MIT","category":"databases-storage","readme_excerpt":"Rate limit made simple, easy, async. Based on ratelimiter. Install Usage The most straightforward way to use the rate limiter: For scenarios where you want to check the limit status before consuming a request, you should to pass { peek: true } : API constructor(options) It creates an rate limiter instance. options db Required Type: object The redis connection instance. max Type: number Default: 2500 The maximum number of requests within duration . duration Type: number Default: 3600000 How long keep records of requests in milliseconds. namespace Type: string Default: 'limit' The prefix used for compound the key. id Type: string The identifier to limit against (typically a user id). You can pass this value using when you use .get method as well. .get(options) Given an id , returns a Promise with the status of the limit with the following structure: - total : max value. - remaining : number of calls left in current duration without decreasing current get . - reset : time since epoch in seconds that the rate limiting period will end (or already ended). options id Type: string Default: this.id The identifier to limit against (typically a user id). max Type: number Default: this.max The maximum number of requests within duration . If provided, it overrides the default max value. This is useful for custom limits that differ between IDs. duration Type: number Default: this.duration How long keep records of requests in milliseconds. If provided, it overrides the default duration valu","default_branch":null,"files":null,"tree":[],"storefront":"/r/microlinkhq","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/microlinkhq/async-ratelimiter/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}