mirror of
https://github.com/itsnaveenk/bazar3.git
synced 2025-12-19 23:37:05 +00:00
14 lines
355 B
JavaScript
14 lines
355 B
JavaScript
const { RateLimiterMemory } = require('rate-limiter-flexible');
|
|
|
|
const publicLimiter = new RateLimiterMemory({
|
|
points: 1000,
|
|
duration: 60
|
|
});
|
|
|
|
module.exports = {
|
|
publicLimiter: (req, res, next) => {
|
|
publicLimiter.consume(req.anonymizedIP)
|
|
.then(() => next())
|
|
.catch(() => res.status(429).json({ error: 'Too many requests' }));
|
|
}
|
|
}; |