Skip to content

Commit

Permalink
Merge pull request #205 from Sachinsharma01/issue-56-api-rate-limit
Browse files Browse the repository at this point in the history
⚡ Added API Rate Limit as described in issue 56
  • Loading branch information
naelob authored Dec 29, 2023
2 parents 0bc766c + 74e46f9 commit 12d82db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@nestjs/platform-express": "^10.0.0",
"@nestjs/schedule": "^4.0.0",
"@nestjs/swagger": "^7.1.14",
"@nestjs/throttler": "^5.1.1",
"@ntegral/nestjs-sentry": "^4.0.0",
"@prisma/client": "^5.4.2",
"@sentry/node": "^7.80.0",
Expand Down
13 changes: 12 additions & 1 deletion packages/api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import { AtsModule } from './ats/ats.module';
import { AccountingModule } from './accounting/accounting.module';
import { FileStorageModule } from './file-storage/file-storage.module';
import { SentryInterceptor, SentryModule } from '@ntegral/nestjs-sentry';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
import { LoggerService } from '@@core/logger/logger.service';
import { CoreModule } from '@@core/core.module';
import { BullModule } from '@nestjs/bull';
import { TicketingModule } from '@ticketing/ticketing.module';
import { ThrottlerGuard, ThrottlerModule } from '@nestjs/throttler';

@Module({
imports: [
Expand All @@ -28,6 +29,12 @@ import { TicketingModule } from '@ticketing/ticketing.module';
FileStorageModule,
CrmModule,
TicketingModule,
ThrottlerModule.forRoot([
{
ttl: parseInt(process.env.THROTTLER_TTL),
limit: parseInt(process.env.THROTTLER_LIMIT)
},
]),
ConfigModule.forRoot({ isGlobal: true }),
...(process.env.DISTRIBUTION === 'managed'
? [
Expand Down Expand Up @@ -66,6 +73,10 @@ import { TicketingModule } from '@ticketing/ticketing.module';
AppService,
TasksService,
LoggerService,
{
provide: APP_GUARD,
useClass: ThrottlerGuard,
},
{
provide: APP_INTERCEPTOR,
useFactory: () =>
Expand Down

0 comments on commit 12d82db

Please sign in to comment.