rate limitter

This commit is contained in:
iqubik
2026-04-04 23:37:34 +03:00
parent 3d4b45ad01
commit cad277a712
3 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ import { SessionModule } from './session/session.module';
ThrottlerModule.forRoot([
{
ttl: 60000,
limit: 5,
limit: 1000,
},
]),
TypeOrmModule.forRoot({
+3
View File
@@ -10,6 +10,7 @@ import {
Query,
Logger,
} from '@nestjs/common';
import { Throttle } from '@nestjs/throttler';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import type { Response, Request } from 'express';
@@ -34,6 +35,7 @@ export class ClientController {
) {}
@Public()
@Throttle({ default: { limit: 300, ttl: 60000 } })
@Get('bus/:uuid')
async getSubscription(
@Param('uuid') uuid: string,
@@ -92,6 +94,7 @@ export class ClientController {
}
@Public()
@Throttle({ default: { limit: 300, ttl: 60000 } })
@Get('bus/:uuid/:tunnelId')
async getRelaySubscription(
@Param('uuid') uuid: string,
+2 -2
View File
@@ -28,7 +28,7 @@ describe('AppModule конфигурация', () => {
delete process.env.JWT_SECRET;
});
it('должен регистрировать ThrottlerModule с лимитом 5/60000ms', () => {
it('должен регистрировать ThrottlerModule с лимитом 1000/60000ms (лояльный API)', () => {
const imports = (Reflect.getMetadata(MODULE_METADATA.IMPORTS, AppModule) ??
[]) as DynamicModuleLike[];
const throttlerDynamicModule = imports.find(
@@ -43,7 +43,7 @@ describe('AppModule конфигурация', () => {
expect(throttlerOptionsProvider?.useValue).toEqual(
expect.arrayContaining([
expect.objectContaining({
limit: 5,
limit: 1000,
ttl: 60000,
}),
]),