nestjs-security-module
Version:
A plug-and-play NestJS security module with CORS, Helmet, rate limiting, audit logging, CSP, XSS sanitization, and more.
16 lines (14 loc) • 559 B
text/typescript
import rateLimit from 'express-rate-limit';
import { RequestHandler } from 'express';
export function createRateLimitMiddleware(options?: {
windowMs?: number;
max?: number;
}): RequestHandler {
return rateLimit({
windowMs: options?.windowMs ?? 60_000, // default: 1 dakika
max: options?.max ?? 100, // default: 100 istek/IP
standardHeaders: true, // RateLimit-* header’larını aktif et
legacyHeaders: false, // X-RateLimit-* header’larını kapat
message: 'Çok fazla istek gönderildi, lütfen sonra tekrar deneyin.',
});
}