105 lines
3.1 KiB
TypeScript
105 lines
3.1 KiB
TypeScript
import { Module } from '@nestjs/common'
|
|
import { ConfigModule } from '@nestjs/config'
|
|
import { ScheduleModule } from '@nestjs/schedule'
|
|
import { PassportModule } from '@nestjs/passport'
|
|
import { JwtModule } from '@nestjs/jwt'
|
|
|
|
// Config
|
|
import { appConfig, databaseConfig, redisConfig, kafkaConfig, jwtConfig } from '@/config'
|
|
|
|
// Infrastructure
|
|
import { PrismaService } from '@/infrastructure/persistence/prisma/prisma.service'
|
|
import {
|
|
AuthorizationRoleRepositoryImpl,
|
|
AUTHORIZATION_ROLE_REPOSITORY,
|
|
} from '@/infrastructure/persistence/repositories/authorization-role.repository.impl'
|
|
import {
|
|
MonthlyAssessmentRepositoryImpl,
|
|
MONTHLY_ASSESSMENT_REPOSITORY,
|
|
} 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'
|
|
import { ReferralServiceClient } from '@/infrastructure/external/referral-service.client'
|
|
|
|
// Application
|
|
import { AuthorizationApplicationService, REFERRAL_REPOSITORY, TEAM_STATISTICS_REPOSITORY } from '@/application/services'
|
|
import { MonthlyAssessmentScheduler } from '@/application/schedulers'
|
|
|
|
// API
|
|
import {
|
|
AuthorizationController,
|
|
AdminAuthorizationController,
|
|
HealthController,
|
|
InternalAuthorizationController,
|
|
} from '@/api/controllers'
|
|
|
|
// Shared
|
|
import { JwtStrategy } from '@/shared/strategies'
|
|
|
|
// Mock repositories for external services (should be replaced with actual implementations)
|
|
const MockReferralRepository = {
|
|
provide: REFERRAL_REPOSITORY,
|
|
useValue: {
|
|
findByUserId: async () => null,
|
|
getAllAncestors: async () => [],
|
|
getAllDescendants: async () => [],
|
|
},
|
|
}
|
|
|
|
@Module({
|
|
imports: [
|
|
ConfigModule.forRoot({
|
|
isGlobal: true,
|
|
load: [appConfig, databaseConfig, redisConfig, kafkaConfig, jwtConfig],
|
|
}),
|
|
ScheduleModule.forRoot(),
|
|
PassportModule.register({ defaultStrategy: 'jwt' }),
|
|
JwtModule.registerAsync({
|
|
useFactory: () => ({
|
|
secret: process.env.JWT_SECRET,
|
|
signOptions: { expiresIn: process.env.JWT_EXPIRES_IN || '7d' },
|
|
}),
|
|
}),
|
|
RedisModule,
|
|
KafkaModule,
|
|
],
|
|
controllers: [
|
|
AuthorizationController,
|
|
AdminAuthorizationController,
|
|
HealthController,
|
|
InternalAuthorizationController,
|
|
EventConsumerController,
|
|
],
|
|
providers: [
|
|
// Prisma
|
|
PrismaService,
|
|
|
|
// Repositories
|
|
{
|
|
provide: AUTHORIZATION_ROLE_REPOSITORY,
|
|
useClass: AuthorizationRoleRepositoryImpl,
|
|
},
|
|
{
|
|
provide: MONTHLY_ASSESSMENT_REPOSITORY,
|
|
useClass: MonthlyAssessmentRepositoryImpl,
|
|
},
|
|
MockReferralRepository,
|
|
|
|
// External Service Clients (replaces mock)
|
|
ReferralServiceClient,
|
|
{
|
|
provide: TEAM_STATISTICS_REPOSITORY,
|
|
useExisting: ReferralServiceClient,
|
|
},
|
|
|
|
// Application Services
|
|
AuthorizationApplicationService,
|
|
MonthlyAssessmentScheduler,
|
|
|
|
// Strategies
|
|
JwtStrategy,
|
|
],
|
|
})
|
|
export class AppModule {}
|