import { Global, Module } from '@nestjs/common';
import { createLogService, type LogService } from '@mosaicstack/log';
import type { Db } from '@mosaicstack/db';
import { DB } from '../database/database.module.js';
import { LOG_SERVICE } from './log.tokens.js';
import { LogController } from './log.controller.js';
import { SummarizationService } from './summarization.service.js';
import { CronService } from './cron.service.js';
import { GCModule } from '../gc/gc.module.js';
import { QueueModule } from '../queue/queue.module.js';

@Global()
@Module({
  imports: [GCModule, QueueModule],
  providers: [
    {
      provide: LOG_SERVICE,
      useFactory: (db: Db): LogService => createLogService(db),
      inject: [DB],
    },
    SummarizationService,
    CronService,
  ],
  controllers: [LogController],
  exports: [LOG_SERVICE, SummarizationService],
})
export class LogModule {}
