Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: redis throttler

Nevo Davidff89a21c988b
diff --git a/apps/backend/src/app.module.ts b/apps/backend/src/app.module.ts
index 64135061d..7a0be2d0b 100644
--- a/apps/backend/src/app.module.ts
+++ b/apps/backend/src/app.module.ts
@@ -15,6 +15,8 @@ import { ChatModule } from '@gitroom/nestjs-libraries/chat/chat.module';
import { getTemporalModule } from '@gitroom/nestjs-libraries/temporal/temporal.module';
import { TemporalRegisterMissingSearchAttributesModule } from '@gitroom/nestjs-libraries/temporal/temporal.register';
import { InfiniteWorkflowRegisterModule } from '@gitroom/nestjs-libraries/temporal/infinite.workflow.register';
+import { ThrottlerStorageRedisService } from '@nest-lab/throttler-storage-redis';
+import { ioRedis } from '@gitroom/nestjs-libraries/redis/redis.service';
@Global()
@Module({
@@ -30,12 +32,15 @@ import { InfiniteWorkflowRegisterModule } from '@gitroom/nestjs-libraries/tempor
getTemporalModule(false),
TemporalRegisterMissingSearchAttributesModule,
InfiniteWorkflowRegisterModule,
- ThrottlerModule.forRoot([
- {
- ttl: 3600000,
- limit: process.env.API_LIMIT ? Number(process.env.API_LIMIT) : 30,
- },
- ]),
+ ThrottlerModule.forRoot({
+ throttlers: [
+ {
+ ttl: 3600000,
+ limit: process.env.API_LIMIT ? Number(process.env.API_LIMIT) : 30,
+ },
+ ],
+ storage: new ThrottlerStorageRedisService(ioRedis),
+ }),
],
controllers: [],
providers: [
diff --git a/package.json b/package.json
index ae995bb3f..787c795c9 100644
--- a/package.json
+++ b/package.json
@@ -66,6 +66,7 @@
"@mastra/memory": "^0.15.6",
"@mastra/pg": "^0.17.2",
"@modelcontextprotocol/sdk": "^1.22.0",
+ "@nest-lab/throttler-storage-redis": "^1.2.0",
"@nestjs/cli": "10.0.2",
"@nestjs/common": "^10.0.2",
"@nestjs/core": "^10.0.2",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d41077cbd..447aa9eb4 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -84,6 +84,9 @@ importers:
'@modelcontextprotocol/sdk':
specifier: ^1.22.0
+ '@nest-lab/throttler-storage-redis':
+ specifier: ^1.2.0
'@nestjs/cli':
specifier: 10.0.2
@@ -3748,6 +3751,15 @@ packages:
'@neon-rs/[email protected]':
resolution: {integrity: sha512-H4Gu2o5kPp+JOEhRrOQCnJnf7X6sv9FBLttM/wSbb4efsgFWeHzfU/ItZ01E5qqEk+U6QGdeVO7lxXIAtYHr5A==}
+ '@nest-lab/[email protected]':
+ resolution: {integrity: sha512-tMkUyo68NCKTR+zILk+EC35SMYBtDPZY2mCj7ZaCietWGVTnuP4zwq9ERYfvU6kJv6h8teNZrC6MJCmY6/dljw==}
+ peerDependencies:
+ '@nestjs/common': ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0
+ '@nestjs/core': ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0
+ '@nestjs/throttler': '>=6.0.0'
+ ioredis: '>=5.0.0'
+ reflect-metadata: ^0.2.1
+
'@nestjs/[email protected]':
resolution: {integrity: sha512-68pFJgu+/AZbWkGu65Z3r55bTsCPlgyKaV4BSG8yUAD72q1PPuyVRgUwFv6BxdnibTUHlyxm06FmYWNC+bjN7A==}
peerDependencies:
@@ -16734,10 +16746,12 @@ packages:
resolution: {integrity: sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==}
engines: {node: '>=12'}
+ deprecated: Use @exodus/bytes instead for a more spec-conformant and faster implementation
resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==}
engines: {node: '>=18'}
+ deprecated: Use @exodus/bytes instead for a more spec-conformant and faster implementation
resolution: {integrity: sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==}
@@ -21037,6 +21051,15 @@ snapshots:
'@neon-rs/[email protected]': {}
+ dependencies:
+ ioredis: 5.8.2
+ reflect-metadata: 0.1.14
+ tslib: 2.8.1
+
dependencies: