foortex.codegen utility
ExpressSecurity 1950 68.3k

Express.js Redis API Rate Limiting & DDoS Prevention

Production Express.js middleware using rate-limiter-flexible and ioredis. Implements dual-tier rate limiting (burst protection + long-term quota limit), IP spoofing validation, and customized JSON error responses.

Powered by rate-limiter-flexible and ioredis
Automatic fallthrough to memory driver
Interactive Prompt & Options
Fully Editable

Appended directly to the LLM system prompt for tailored code output.

✨ OpenRouter LLM Engine (Llama-3.3-70B) Active

Generated Code

⚡ Instant Boilerplate
express-rate-limit-redis.ts
1const { RateLimiterRedis } = require('rate-limiter-flexible');
2const Redis = require('ioredis');
3const redisClient = new Redis(process.env.REDIS_URL || 'redis://localhost:6379');
4const rateLimiter = new RateLimiterRedis({ storeClient: redisClient, points: 60, duration: 60 });
5
6const rateLimitMiddleware = async (req, res, next) => {
7 try {
8 await rateLimiter.consume(req.ip);
9 next();
10 } catch (err) {
11 res.status(429).json({ error: 'Too Many Requests' });
12 }
13};
14module.exports = { rateLimitMiddleware };
15
15 lines • 518 bytesexpress
Automated Sandbox

Deploy this boilerplate automatically in 1 click.

Deploy