Basic IP rate-limiting middleware for Hyper-express. Use to limit repeated requests to public APIs and/or endpoints such as password reset.
npm install hyper-express-rate-limithyper-express-rate-limit Basic rate-limiting middleware for Hyper-express. Use to
limit repeated requests to public APIs and/or endpoints such as password reset.
``ts
import { rateLimit } from 'hyper-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).RateLimit-*
standardHeaders: 'draft-7', // draft-6: headers; draft-7: combined RateLimit headerX-RateLimit-*
legacyHeaders: false, // Disable the headers.
// store: ... , // Use an external store for consistency across multiple server instances.
})
// Apply the rate limiting middleware to all requests.
app.use(limiter)
`
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!
Thanks to Nathan Friedly, Vedant K