-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from viniciuscosmome/feat/rate-limit
Feat/rate limit
- Loading branch information
Showing
8 changed files
with
57 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ThrottlerModule } from '@nestjs/throttler'; | ||
import { throttlerConfig } from './config/throttler'; | ||
import { AccountModule, TaskModule, GoalModule } from './modules'; | ||
|
||
@Module({ | ||
imports: [AccountModule, TaskModule, GoalModule], | ||
imports: [ | ||
ThrottlerModule.forRoot(throttlerConfig), | ||
AccountModule, | ||
TaskModule, | ||
GoalModule, | ||
], | ||
}) | ||
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ThrottlerOptions, ThrottlerModuleOptions } from '@nestjs/throttler'; | ||
|
||
export const throttlers: Array<ThrottlerOptions> = [ | ||
{ | ||
ttl: 1000, | ||
limit: 3, | ||
}, | ||
{ | ||
ttl: 10000, | ||
limit: 20, | ||
}, | ||
]; | ||
|
||
export const throttlerConfig: ThrottlerModuleOptions = { | ||
throttlers: throttlers, | ||
errorMessage: 'Você fez muitas requisições em um curto periodo de tempo.', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters