Test/prevent server block on rate limit (#414)

* task: test rate limits on sever
This commit is contained in:
ZaydSkaff
2025-06-19 09:45:09 +03:00
committed by GitHub
parent a37d5bb299
commit 705ceeba29

View File

@ -9,9 +9,10 @@ import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
import { setupSwaggerAuthentication } from '../libs/common/src/util/user-auth.swagger.utils';
import { AppModule } from './app.module';
import { HttpExceptionFilter } from './common/filters/http-exception/http-exception.filter';
import { NestExpressApplication } from '@nestjs/platform-express';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.enableCors();
@ -21,11 +22,12 @@ async function bootstrap() {
app.useGlobalFilters(new HttpExceptionFilter());
app.use(new RequestContextMiddleware().use);
app.set('trust proxy', true);
app.use(
rateLimit({
windowMs: 5 * 60 * 1000,
max: 500,
windowMs: 30 * 1000,
max: 50,
standardHeaders: true,
legacyHeaders: false,
}),
@ -36,7 +38,7 @@ async function bootstrap() {
next();
});
app.getHttpAdapter().getInstance().set('trust proxy', 1);
// app.getHttpAdapter().getInstance().set('trust proxy', 1);
app.use(
helmet({