feat: add throttle
This commit is contained in:
@@ -10,7 +10,9 @@ import {
|
||||
Query,
|
||||
Req,
|
||||
Res,
|
||||
UseGuards,
|
||||
} from '@nestjs/common'
|
||||
import { Throttle, ThrottlerGuard } from '@nestjs/throttler'
|
||||
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { HTTPDecorators } from '~/common/decorator/http.decorator'
|
||||
@@ -45,6 +47,8 @@ export class FileController {
|
||||
}
|
||||
|
||||
@Get('/:type/:name')
|
||||
@UseGuards(ThrottlerGuard)
|
||||
@Throttle(10, 60)
|
||||
@HTTPDecorators.Bypass
|
||||
async get(@Param() params: FileQueryDto, @Res() reply: FastifyReply) {
|
||||
const { type, name } = params
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Global, Module, Provider, forwardRef } from '@nestjs/common'
|
||||
import { EventEmitterModule } from '@nestjs/event-emitter'
|
||||
import { ScheduleModule } from '@nestjs/schedule'
|
||||
import { ThrottlerModule } from '@nestjs/throttler'
|
||||
|
||||
import { AggregateModule } from '~/modules/aggregate/aggregate.module'
|
||||
import { BackupModule } from '~/modules/backup/backup.module'
|
||||
@@ -36,6 +37,7 @@ const providers: Provider<any>[] = [
|
||||
@Module({
|
||||
imports: [
|
||||
ScheduleModule.forRoot(),
|
||||
ThrottlerModule.forRoot({}),
|
||||
EventEmitterModule.forRoot({
|
||||
wildcard: false,
|
||||
// the delimiter used to segment namespaces
|
||||
|
||||
Reference in New Issue
Block a user