Skip to content

Commit

Permalink
fix(api): add redis-based throttler back
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcfps committed Jan 24, 2025
1 parent 1bf7358 commit 1a5c3d4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions apps/api/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ExecutionContext, Module } from '@nestjs/common';
import { BullModule } from '@nestjs/bullmq';
import { APP_GUARD } from '@nestjs/core';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { LoggerModule } from 'nestjs-pino';
import { SkipThrottle, ThrottlerGuard, ThrottlerModule, seconds } from '@nestjs/throttler';
import { ThrottlerStorageRedisService } from '@nest-lab/throttler-storage-redis';
import api from '@opentelemetry/api';

import { CommonModule } from '@/common/common.module';
Expand All @@ -25,7 +27,6 @@ import { CanvasModule } from './canvas/canvas.module';
import { CollabModule } from './collab/collab.module';
import { ActionModule } from './action/action.module';
import { RedisService } from '@/common/redis.service';
import { APP_GUARD } from '@nestjs/core';

class CustomThrottlerGuard extends ThrottlerGuard {
protected async shouldSkip(context: ExecutionContext): Promise<boolean> {
Expand Down Expand Up @@ -60,7 +61,7 @@ class CustomThrottlerGuard extends ThrottlerGuard {
},
],
getTracker: (req) => (req.ips?.length ? req.ips[0] : req.ip),
// storage: new ThrottlerStorageRedisService(redis),
storage: new ThrottlerStorageRedisService(redis),
}),
}),
LoggerModule.forRoot({
Expand Down

0 comments on commit 1a5c3d4

Please sign in to comment.