| import rateLimit from 'express-rate-limit';
|
|
|
| const windowMs = process.env.RATE_LIMIT_WINDOW_MS ? parseInt(process.env.RATE_LIMIT_WINDOW_MS, 10) : 15 * 60 * 1000;
|
| const maxRequests = process.env.RATE_LIMIT_MAX_REQUESTS ? parseInt(process.env.RATE_LIMIT_MAX_REQUESTS, 10) : 5;
|
|
|
|
|
| export const publicFormLimiter = rateLimit({
|
| windowMs,
|
| max: maxRequests,
|
| standardHeaders: true,
|
| legacyHeaders: false,
|
| message: {
|
| error: "Too many requests",
|
| details: "Please try again later after 15 minutes",
|
| }
|
| });
|
|
|
|
|
| export const authLimiter = rateLimit({
|
| windowMs: 15 * 60 * 1000,
|
| max: 10,
|
| standardHeaders: true,
|
| legacyHeaders: false,
|
| message: {
|
| error: "Too many login attempts",
|
| details: "Account temporarily locked for 15 minutes due to too many failed attempts"
|
| }
|
| });
|
|
|