rate-limiter-flexible 是一个功能强大的速率限制库,支持多种存储后端(如 Redis、MongoDB 等),并提供灵活的配置选项。它允许开发者设置复杂的速率限制规则,并支持 IP 地址、用户 ID 等多种限制方式。rate-limiter-flexible 适合需要高度可定制和可扩展速率限制解决方案的应用程序。
express-brute 是一个强大的速率限制中间件,旨在防止暴力破解攻击。它允许开发者根据不同的策略来限制请求,例如基于 IP 地址、用户 ID 或其他标识符。express-brute 提供了灵活的配置选项,可以与多种存储后端(如内存、Redis、MongoDB 等)一起使用,适合需要复杂速率限制策略的应用程序。
express-brute 是一个灵活的速率限制中间件,允许开发者根据不同的条件(如 IP 地址、用户 ID 等)设置请求限制。它支持多种存储后端(如内存、Redis、MongoDB 等),使其适用于各种应用场景。express-brute 的灵活性和可扩展性使其成为需要复杂速率限制策略的项目的理想选择。
Basic rate-limiting middleware for Express. Use to
limit repeated requests to public APIs and/or endpoints such as password reset.
Plays nice with
express-slow-down and
ratelimit-header-parser.
import { rateLimit } from 'express-rate-limit'
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
limit: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes).
standardHeaders: 'draft-8', // draft-6: `RateLimit-*` headers; draft-7 & draft-8: combined `RateLimit` header
legacyHeaders: false, // Disable the `X-RateLimit-*` headers.
ipv6Subnet: 56, // Set to 60 or 64 to be less aggressive, or 52 or 48 to be more aggressive
// store: ... , // Redis, Memcached, etc. See below.
})
// Apply the rate limiting middleware to all requests.
app.use(limiter)
Data Stores
The rate limiter comes with a built-in memory store, and supports a variety of
external data stores.
Configuration
All function options may be async. Click the name for additional info and
default values.
Sponsored by Zuplo a fully-managed API
Gateway for developers. Add
dynamic rate-limiting,
authentication and more to any API in minutes. Learn more at
zuplo.com
Finally, thank you to everyone who's contributed to this project in any way! 🫶
Issues and Contributing
If you encounter a bug or want to see something added/changed, please go ahead
and
open an issue!
If you need help with something, feel free to
start a discussion!
If you wish to contribute to the library, thanks! First, please read
the contributing guide.
Then you can pick up any issue and fix/implement it!