@ar-packages-changeit/rate-limited-axios
v1.1.1
Published
A lightweight rate-limiting wrapped Axios that helps control the number of HTTP requests and prevent API throttling.
Downloads
10
Readme
@rosen-clients/rate-limited-axios
Table of contents
Introduction
A lightweight rate-limiting interceptor for Axios that helps control the number of HTTP requests and prevent API throttling.
Installation
npm:
npm i @rosen-clients/rate-limited-axiosyarn:
yarn add @rosen-clients/rate-limited-axiosUsage
To enable global rate-limiting across your application, you should initialize the configuration once at the entry point of your project (e.g., index.ts or bootstrap.ts):
import RateLimitedAxios, { RateLimitedAxiosConfig } from '@rosen-clients/rate-limited-axios';
RateLimiterAxiosConfig.addRule('^http://google.com/.*$', 10, 30, 90);
RateLimiterAxiosConfig.addRule('^http://yahoo.com/.*$', 10, 30, 90);
RateLimiterAxiosConfig.addRule('^http://bing.com/.*$', 10, 30, 90);
.
.
.
const axiosClient = new RateLimitedAxios();
for (let i = 0; i < 10; i++)
axiosClient.get(url);After this initialization, all packages that import and use @rosen-clients/rate-limited-axios will respect the configured request limits, ensuring consistent throttling behavior across your entire application.
