
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Library for managing rate limits. Has high level requests limiter, and low level token limiter, and will queue requests if limit is reached.
$ npm install limitie
Lets say you have a site that only lets you make 10 requests per second across all of its API endpoints. You could create a limiter for that service and use it in all of the methods for that service.
import createLimitie from 'limitie';
// Create a rate limiter for this service, limiting all requests through this limiter to
// 10 per second.
// Any requests in excess of that amount will be queued up and updated when available.
const limitie = createLimitie({ requests: 10, interval: 1000 });
async function listItems() {
await limitie.request();
// List items from this service
}
async function getDetailedItem(itemId: string) {
await limitie.request();
// Get detailed info for this item
}
Tokens are a lower level abstraction than requests. This could be used for services that have a rate limit in place of something like 50000 tokens per minute. In that case, you would build a rate limiter like this:
import createLimitie from 'limitie';
// Create a rate limiter for this service, limiting all requests through this limiter to
// 50000 tokens per minute.
const limitie = createLimitie({
tokens: {
regen: 50000,
},
interval: 1000,
});
async function listItems() {
// Here we use the lower level reserve API, where we can specify a specific number of tokens for this request.
await limitie.reserve(10000).promise();
// List items from this service
}
async function getDetailedItem(itemId: string) {
// Here we use the lower level reserve API, where we can specify a specific number of tokens for this request.
await limitie.reserve(500).promise();
// Get detailed info for this item
}
// Create a rate limiter for this service, limiting all requests through this limiter to
// 50000 tokens per minute.
// This service starts us off at 0 tokens, though, so we have to wait for tokens to regen
// before we can make requests, so we pass tokens.initial of 0.
// This service also allows us to pool up tokens to a maximum of 99999, so we can pass
// tokens.max of 99999
const limitie = createLimitie({
tokens: {
max: 99999,
regen: 50000,
initial: 0,
},
interval: 1000,
});
Let's say I've reserved to use 50 tokens, but I have to wait until they're available. This means that the limiter has handled all of the reserved cases before mine, and that sufficient tokens have pooled to accommodate the request.
const reservation = limitie.reserve(50);
// I can see the time left until this is handled by doing
const timeLeft = limitie.getTimeUntilReady(reservation.id);
// And it is awaited like this
await reservation.promise;
We welcome contributions! Please see our contributing guidelines for more information.
MIT
FAQs
Library for managing rate limits. Has high level requests limiter, and low level token limiter, and will queue requests if limit is reached.
We found that limitie demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.