import { Module } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { DomainModule } from '../domain/domain.module';
import { InfrastructureModule } from '../infrastructure/infrastructure.module';
import { RecordEventsHandler } from './commands/record-events/record-events.handler';
import { RecordHeartbeatHandler } from './commands/record-heartbeat/record-heartbeat.handler';
import { CalculateDauHandler } from './commands/calculate-dau/calculate-dau.handler';
import { GetOnlineCountHandler } from './queries/get-online-count/get-online-count.handler';
import { GetDauStatsHandler } from './queries/get-dau-stats/get-dau-stats.handler';
import { GetOnlineHistoryHandler } from './queries/get-online-history/get-online-history.handler';
import { AnalyticsScheduler } from './schedulers/analytics.scheduler';

const CommandHandlers = [
  RecordEventsHandler,
  RecordHeartbeatHandler,
  CalculateDauHandler,
];

const QueryHandlers = [
  GetOnlineCountHandler,
  GetDauStatsHandler,
  GetOnlineHistoryHandler,
];

@Module({
  imports: [CqrsModule, DomainModule, InfrastructureModule],
  providers: [
    ...CommandHandlers,
    ...QueryHandlers,
    AnalyticsScheduler,
  ],
  exports: [CqrsModule],
})
export class ApplicationModule {}
