11import { Logger , Module } from '@nestjs/common' ;
22import { ConfigModule , ConfigService } from '@nestjs/config' ;
33import { MongooseModule , MongooseModuleFactoryOptions } from '@nestjs/mongoose' ;
4- import { ThrottlerModule } from '@nestjs/throttler' ;
4+ import { ThrottlerGuard , ThrottlerModule } from '@nestjs/throttler' ;
55import { MailerModule } from '@nestjs-modules/mailer' ;
66import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter' ;
77
@@ -15,6 +15,7 @@ import { SeedModule } from './seed/seed.module';
1515import { SongModule } from './song/song.module' ;
1616import { SongBrowserModule } from './song-browser/song-browser.module' ;
1717import { UserModule } from './user/user.module' ;
18+ import { APP_GUARD } from '@nestjs/core' ;
1819
1920@Module ( {
2021 imports : [
@@ -67,19 +68,8 @@ import { UserModule } from './user/user.module';
6768 // Throttler
6869 ThrottlerModule . forRoot ( [
6970 {
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
8373 } ,
8474 ] ) ,
8575 SongModule ,
@@ -92,7 +82,13 @@ import { UserModule } from './user/user.module';
9282 MailingModule ,
9383 ] ,
9484 controllers : [ ] ,
95- providers : [ ParseTokenPipe ] ,
85+ providers : [
86+ ParseTokenPipe ,
87+ {
88+ provide : APP_GUARD ,
89+ useClass : ThrottlerGuard ,
90+ } ,
91+ ] ,
9692 exports : [ ParseTokenPipe ] ,
9793} )
9894export class AppModule {
0 commit comments