A social knowledge tool for researchers built on ATProto

refactor: remove `as any` cast and improve saga dependency injection

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>

+7 -23
+5 -16
src/shared/infrastructure/http/factories/ServiceFactory.ts
··· 224 224 }; 225 225 } 226 226 227 - // Create saga with appropriate state store 228 - let cardCollectionSaga: CardCollectionSaga; 229 - if (useInMemoryEvents) { 230 - const stateStore = new InMemorySagaStateStore(); 231 - cardCollectionSaga = new CardCollectionSaga( 232 - sharedServices.feedService as any, // Will be properly typed when used 233 - stateStore, 234 - ); 235 - } else { 236 - const stateStore = new RedisSagaStateStore(redisConnection!); 237 - cardCollectionSaga = new CardCollectionSaga( 238 - sharedServices.feedService as any, // Will be properly typed when used 239 - stateStore, 240 - ); 241 - } 227 + // Create appropriate saga state store 228 + const sagaStateStore = useInMemoryEvents 229 + ? new InMemorySagaStateStore() 230 + : new RedisSagaStateStore(redisConnection!); 242 231 243 232 return { 244 233 ...sharedServices, 245 234 redisConnection: redisConnection, 246 235 eventPublisher, 247 236 createEventSubscriber, 248 - cardCollectionSaga, 237 + sagaStateStore, 249 238 }; 250 239 } 251 240
+2 -7
src/shared/infrastructure/processes/FeedWorkerProcess.ts
··· 40 40 ): Promise<void> { 41 41 const useCases = UseCaseFactory.createForWorker(repositories, services); 42 42 43 - // Create saga with appropriate state store based on event system type 44 - const useInMemoryEvents = process.env.USE_IN_MEMORY_EVENTS === 'true'; 45 - const stateStore = useInMemoryEvents 46 - ? new InMemorySagaStateStore() 47 - : new RedisSagaStateStore(services.redisConnection!); 48 - 43 + // Create saga with proper use case dependency and state store from services 49 44 const cardCollectionSaga = new CardCollectionSaga( 50 45 useCases.addActivityToFeedUseCase, 51 - stateStore, 46 + services.sagaStateStore, 52 47 ); 53 48 54 49 const cardAddedToLibraryHandler = new CardAddedToLibraryEventHandler(