rate limitter
This commit is contained in:
@@ -31,7 +31,7 @@ import { SessionModule } from './session/session.module';
|
||||
ThrottlerModule.forRoot([
|
||||
{
|
||||
ttl: 60000,
|
||||
limit: 5,
|
||||
limit: 1000,
|
||||
},
|
||||
]),
|
||||
TypeOrmModule.forRoot({
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
}),
|
||||
]),
|
||||
|
||||
Reference in New Issue
Block a user