mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
task: test rate limits on sever
This commit is contained in:
10
src/main.ts
10
src/main.ts
@ -9,9 +9,10 @@ import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
|
|||||||
import { setupSwaggerAuthentication } from '../libs/common/src/util/user-auth.swagger.utils';
|
import { setupSwaggerAuthentication } from '../libs/common/src/util/user-auth.swagger.utils';
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
import { HttpExceptionFilter } from './common/filters/http-exception/http-exception.filter';
|
import { HttpExceptionFilter } from './common/filters/http-exception/http-exception.filter';
|
||||||
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
||||||
|
|
||||||
app.enableCors();
|
app.enableCors();
|
||||||
|
|
||||||
@ -21,11 +22,12 @@ async function bootstrap() {
|
|||||||
app.useGlobalFilters(new HttpExceptionFilter());
|
app.useGlobalFilters(new HttpExceptionFilter());
|
||||||
|
|
||||||
app.use(new RequestContextMiddleware().use);
|
app.use(new RequestContextMiddleware().use);
|
||||||
|
app.set('trust proxy', true);
|
||||||
|
|
||||||
app.use(
|
app.use(
|
||||||
rateLimit({
|
rateLimit({
|
||||||
windowMs: 5 * 60 * 1000,
|
windowMs: 30 * 1000,
|
||||||
max: 500,
|
max: 50,
|
||||||
standardHeaders: true,
|
standardHeaders: true,
|
||||||
legacyHeaders: false,
|
legacyHeaders: false,
|
||||||
}),
|
}),
|
||||||
@ -36,7 +38,7 @@ async function bootstrap() {
|
|||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.getHttpAdapter().getInstance().set('trust proxy', 1);
|
// app.getHttpAdapter().getInstance().set('trust proxy', 1);
|
||||||
|
|
||||||
app.use(
|
app.use(
|
||||||
helmet({
|
helmet({
|
||||||
|
Reference in New Issue
Block a user