Express Rate Limit is participating 2021 OSC China Open Source Project Selection , please vote for it!
Express Rate Limit in 2021 OSC China Open Source Project Selection {{projectVoteCount} has been obtained in, please vote for it!
2021 OSC China Open Source Project Selection It is in hot progress. Come and vote for your favorite open source project!
2021 OSC China Open Source Project Selection>>> Midfield Review
Express Rate Limit won the 2021 OSC China Open Source Project Selection "The Best Popularity Project" !
Authorization Agreement MIT
development language JavaScript
operating system Cross platform
Software type Open source software
Open source organizations nothing
region Unknown
deliverer sweet potato
intended for unknown
Recording time 2023-09-06

Software Introduction

Express Rate Limit is a flow control middleware implemented for the ExpressJS framework to restrict access to certain methods or APIs. Express Rate Limit provides memory based and Redis based storage control, which can also be used in distributed environments.

usage method:

 import { rateLimit } from 'express-rate-limit' const limiter = rateLimit({ windowMs: 15 * 60 * 1000, // 15 minutes max: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes) standardHeaders: 'draft-7', // draft-6: RateLimit-* headers; draft-7: combined RateLimit header legacyHeaders: false, // X-RateLimit-* headers // store: ... , //  Use an external store for more precise rate limiting }) // Apply the rate limiting middleware to all requests app.use(limiter)

Support multiple instances:

 import { rateLimit } from 'express-rate-limit' const apiLimiter = rateLimit({ windowMs: 15 * 60 * 1000, // 15 minutes max: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes) standardHeaders: 'draft-7', // draft-6: RateLimit-* headers; draft-7: combined RateLimit header legacyHeaders: false, // X-RateLimit-* headers // store: ... , //  Use an external store for more precise rate limiting }) app.use('/api/', apiLimiter) const createAccountLimiter = rateLimit({ windowMs: 60 * 60 * 1000, // 1 hour max: 5, // Limit each IP to 5 create account requests per `window` (here, per hour) message: 'Too many accounts created from this IP,  please try again after an hour', standardHeaders: 'draft-7', // draft-6: RateLimit-* headers; draft-7: combined RateLimit header legacyHeaders: false, // X-RateLimit-* headers }) app.post('/create-account',  createAccountLimiter,  (request, response) => { //... })

 

Expand to read the full text

code

Gitee index of is
exceed Items for

comment

Click to lead the topic 📣 Post and join the discussion 🔥
No content temporarily
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
No more
No content temporarily
Issued a question and answer
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
No more
No content temporarily
No content temporarily
zero comment
one Collection
 OSCHINA
Log in to view more high-quality content
 Back to top
Top