api-rate-limit

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
a

api-rate-limit

A simple rate limiting package to prevent brute force attacks and abuse by limiting the number of requests from a single IP address or user within a specified time period.

1.0.8
latest
65

Supply Chain Security

100

Vulnerability

69

Quality

76

Maintenance

100

License

AI-detected possible typosquat

Supply chain risk

There is a package with a similar name that is downloaded much more often.

Did you mean

hapi-rate-limit

Unpopular package

Quality

This package is not very popular.

Found 1 instance in 1 package

Version published
Weekly downloads
2
-60%
Maintainers
1
Weekly downloads
 
Created
Issues
0

api-rate-limit

This is a Node.js middleware that implements api rate limiting to ip addressess.Here We can specify how many requests to be sent to server for a specific api.

API Reference

  npm i api-rate-limit

Usage

const rateLimit = require('api-rate-limit')

app.get('/api', rateLimit(10, 60000), (req, res) => {
    // Your route handler logic here
    res.send('Hello, world!');
  });

In the above example, the rate limit is set to 10 requests per minute (time is in the format of milliseconds). If a user makes more than 10 requests within a minute, they will receive a 429 "Too Many Requests" error.

The middleware tracks the number of requests made by each IP address and ensures that the rate limit is not exceeded for any given IP address.

Usage

rateLimit(maxRequests, timeWindow)

Creates a new rate limit middleware that limits the number of requests to maxRequests within the specified timeWindow.

-maxRequests: The maximum number of requests allowed within the time window. -timeWindow: The time window in milliseconds during which the requests are counted.

Authors

FAQs

Package last updated on 07 Apr 2023

Did you know?

Socket

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.

Install

Related posts