fix(authorization-service): fix KafkaModule dependency injection
- Add ClientsModule with KAFKA_SERVICE registration - Add EventAckPublisher to KafkaModule providers/exports - Move EventConsumerController to AppModule (has access to repositories) Resolves: Nest can't resolve dependencies of EventConsumerController 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
3f622eb13c
commit
181eeafb2c
|
|
@ -19,6 +19,7 @@ import {
|
|||
} from '@/infrastructure/persistence/repositories/monthly-assessment.repository.impl'
|
||||
import { RedisModule } from '@/infrastructure/redis/redis.module'
|
||||
import { KafkaModule } from '@/infrastructure/kafka/kafka.module'
|
||||
import { EventConsumerController } from '@/infrastructure/kafka/event-consumer.controller'
|
||||
|
||||
// Application
|
||||
import { AuthorizationApplicationService, REFERRAL_REPOSITORY, TEAM_STATISTICS_REPOSITORY } from '@/application/services'
|
||||
|
|
@ -69,7 +70,7 @@ const MockTeamStatisticsRepository = {
|
|||
RedisModule,
|
||||
KafkaModule,
|
||||
],
|
||||
controllers: [AuthorizationController, AdminAuthorizationController, HealthController],
|
||||
controllers: [AuthorizationController, AdminAuthorizationController, HealthController, EventConsumerController],
|
||||
providers: [
|
||||
// Prisma
|
||||
PrismaService,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,33 @@
|
|||
import { Module, Global } from '@nestjs/common'
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config'
|
||||
import { ClientsModule, Transport } from '@nestjs/microservices'
|
||||
import { EventPublisherService } from './event-publisher.service'
|
||||
import { EventConsumerController } from './event-consumer.controller'
|
||||
import { EventAckPublisher } from './event-ack.publisher'
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
controllers: [EventConsumerController],
|
||||
providers: [EventPublisherService],
|
||||
exports: [EventPublisherService],
|
||||
imports: [
|
||||
ClientsModule.registerAsync([
|
||||
{
|
||||
name: 'KAFKA_SERVICE',
|
||||
imports: [ConfigModule],
|
||||
useFactory: (configService: ConfigService) => ({
|
||||
transport: Transport.KAFKA,
|
||||
options: {
|
||||
client: {
|
||||
clientId: configService.get<string>('KAFKA_CLIENT_ID', 'authorization-service'),
|
||||
brokers: configService.get<string>('KAFKA_BROKERS', 'localhost:9092').split(','),
|
||||
},
|
||||
consumer: {
|
||||
groupId: configService.get<string>('KAFKA_GROUP_ID', 'authorization-service-group'),
|
||||
},
|
||||
},
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
},
|
||||
]),
|
||||
],
|
||||
providers: [EventPublisherService, EventAckPublisher],
|
||||
exports: [EventPublisherService, EventAckPublisher, ClientsModule],
|
||||
})
|
||||
export class KafkaModule {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue