1
1
import { Logger , Module } from '@nestjs/common' ;
2
2
import { ConfigModule , ConfigService } from '@nestjs/config' ;
3
3
import { MongooseModule , MongooseModuleFactoryOptions } from '@nestjs/mongoose' ;
4
- import { ThrottlerModule } from '@nestjs/throttler' ;
4
+ import { ThrottlerGuard , ThrottlerModule } from '@nestjs/throttler' ;
5
5
import { MailerModule } from '@nestjs-modules/mailer' ;
6
6
import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter' ;
7
7
@@ -15,6 +15,7 @@ import { SeedModule } from './seed/seed.module';
15
15
import { SongModule } from './song/song.module' ;
16
16
import { SongBrowserModule } from './song-browser/song-browser.module' ;
17
17
import { UserModule } from './user/user.module' ;
18
+ import { APP_GUARD } from '@nestjs/core' ;
18
19
19
20
@Module ( {
20
21
imports : [
@@ -67,19 +68,8 @@ import { UserModule } from './user/user.module';
67
68
// Throttler
68
69
ThrottlerModule . forRoot ( [
69
70
{
70
- name : 'short' ,
71
- ttl : 1000 ,
72
- limit : 3 ,
73
- } ,
74
- {
75
- name : 'medium' ,
76
- ttl : 10000 ,
77
- limit : 20 ,
78
- } ,
79
- {
80
- name : 'long' ,
81
- ttl : 60000 ,
82
- limit : 100 ,
71
+ ttl : 60 ,
72
+ limit : 256 , // 256 requests per minute
83
73
} ,
84
74
] ) ,
85
75
SongModule ,
@@ -92,7 +82,13 @@ import { UserModule } from './user/user.module';
92
82
MailingModule ,
93
83
] ,
94
84
controllers : [ ] ,
95
- providers : [ ParseTokenPipe ] ,
85
+ providers : [
86
+ ParseTokenPipe ,
87
+ {
88
+ provide : APP_GUARD ,
89
+ useClass : ThrottlerGuard ,
90
+ } ,
91
+ ] ,
96
92
exports : [ ParseTokenPipe ] ,
97
93
} )
98
94
export class AppModule {
0 commit comments