import { Module, OnModuleInit } from '@nestjs/common';
import { EnsureInitialData } from '../../../../../adapters/bootstrap/EnsureInitialData';
import { BootstrapProviders } from './BootstrapProviders';

@Module({
  providers: BootstrapProviders,
})
export class BootstrapModule implements OnModuleInit {
  constructor(private readonly ensureInitialData: EnsureInitialData) {}

  async onModuleInit() {
    console.log('[Bootstrap] Initializing application data...');
    try {
      await this.ensureInitialData.execute();
      console.log('[Bootstrap] Application data initialized successfully');
    } catch (error) {
      console.error('[Bootstrap] Failed to initialize application data:', error);
      throw error;
    }
  }
}