import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ScheduleModule } from '@nestjs/schedule';
import { APP_GUARD, APP_FILTER } from '@nestjs/core';
import { validate } from './config/env.validation';
import { CrmPrismaModule } from './prisma/crm-prisma.module';
import { RedisModule } from './redis/redis.module';
import { AuthModule } from './auth/auth.module';
import { JwtAuthGuard } from './auth/guards/jwt-auth.guard';
import { GlobalExceptionFilter } from './common/filters/global-exception.filter';
import { HealthModule } from './health/health.module';
import { ContactsModule } from './contacts/contacts.module';
import { ActivitiesModule } from './activities/activities.module';
import { PipelinesModule } from './pipelines/pipelines.module';
import { DealsModule } from './deals/deals.module';
import { CompaniesModule } from './companies/companies.module';
import { LexwareModule } from './lexware/lexware.module';
import { IndustriesModule } from './industries/industries.module';
import { AccountTypesModule } from './account-types/account-types.module';
import { RelationshipTypesModule } from './relationship-types/relationship-types.module';
import { CompanyRelationshipsModule } from './company-relationships/company-relationships.module';
import { TradeEventsModule } from './trade-events/trade-events.module';
import { CrmEventsModule } from './events/crm-events.module';
import { CustomFieldsModule } from './custom-fields/custom-fields.module';
import { ImportModule } from './import/import.module';
import { EnrichmentModule } from './enrichment/enrichment.module';
import { ContractsModule } from './contracts/contracts.module';
import { GraphModule } from './graph/graph.module';
import { DealTypesModule } from './deal-types/deal-types.module';

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      validate,
    }),
    ScheduleModule.forRoot(),
    CrmPrismaModule,
    RedisModule,
    AuthModule,
    HealthModule,
    ContactsModule,
    ActivitiesModule,
    PipelinesModule,
    DealsModule,
    CompaniesModule,
    LexwareModule,
    IndustriesModule,
    AccountTypesModule,
    RelationshipTypesModule,
    CompanyRelationshipsModule,
    TradeEventsModule,
    CrmEventsModule,
    CustomFieldsModule,
    ImportModule,
    EnrichmentModule,
    ContractsModule,
    GraphModule,
    DealTypesModule,
  ],
  providers: [
    {
      provide: APP_GUARD,
      useClass: JwtAuthGuard,
    },
    {
      provide: APP_FILTER,
      useClass: GlobalExceptionFilter,
    },
  ],
})
export class AppModule {}
