Browse Source

feat(redis): update scan method to handle variadic arguments with type casting

Dave 2 months ago
parent
commit
57e7c6b39f

+ 2 - 2
apps/box-app-api/src/rabbitmq/rabbitmq.module.ts

@@ -1,5 +1,5 @@
 // apps/box-app-api/src/rabbitmq/rabbitmq.module.ts
-import { Module } from '@nestjs/common';
+import { Module, forwardRef } from '@nestjs/common';
 import { ConfigModule } from '@nestjs/config';
 import { RabbitmqPublisherService } from './rabbitmq-publisher.service';
 import { RabbitmqFallbackReplayService } from './rabbitmq-fallback-replay.service';
@@ -9,7 +9,7 @@ import { RedisModule } from '@box/db/redis/redis.module';
 import { AuthModule } from '../feature/auth/auth.module';
 
 @Module({
-  imports: [ConfigModule, RedisModule, AuthModule],
+  imports: [ConfigModule, RedisModule, forwardRef(() => AuthModule)],
   controllers: [RabbitmqFallbackReplayController, RabbitmqStatusController],
   providers: [RabbitmqPublisherService, RabbitmqFallbackReplayService],
   exports: [RabbitmqPublisherService, RabbitmqFallbackReplayService],

+ 4 - 1
libs/db/src/redis/redis.service.ts

@@ -119,13 +119,16 @@ export class RedisService {
    * SCAN cursor-based iteration (non-blocking alternative to KEYS)
    * Returns [nextCursor, keys[]]
    * Use cursor='0' to start, repeat until cursor='0' again
+   *
+   * Example: scan('0', 'MATCH', 'pattern:*', 'COUNT', 100)
    */
   async scan(
     cursor: string,
     ...args: (string | number)[]
   ): Promise<[string, string[]]> {
     const client = this.ensureClient();
-    return client.scan(cursor, ...args);
+    // Cast to any to work around ioredis typing complexity with variadic args
+    return (client.scan as any)(cursor, ...args) as Promise<[string, string[]]>;
   }
 
   /**