import { MikroOrmModule } from '@mikro-orm/nestjs';
import { Module } from '@nestjs/common';
import dataBaseConfig from './config/mikro-orm.config';
import { ConfigModule } from '@nestjs/config';
import { UserModule } from './modules/users/user.module';
import { UtilsModule } from './modules/utils/utils.module';
import { AuthModule } from './modules/auth/auth.module';
import { UploaderModule } from './modules/uploader/uploader.module';
import { AdminModule } from './modules/admin/admin.module';
import { ThrottlerModule } from '@nestjs/throttler';
import { ScheduleModule } from '@nestjs/schedule';
import { RestaurantsModule } from './modules/restaurants/restaurants.module';
import { FoodModule } from './modules/foods/food.module';
import { CartModule } from './modules/cart/cart.module';
import { RolesModule } from './modules/roles/roles.module';
import { PaymentsModule } from './modules/payments/payments.module';
import { DeliveryModule } from './modules/delivery/delivery.module';
import { OrdersModule } from './modules/orders/orders.module';
import { CouponModule } from './modules/coupons/coupon.module';
import { ReviewModule } from './modules/review/review.module';
import { NotificationsModule } from './modules/notifications/notifications.module';
import { EventEmitterModule } from '@nestjs/event-emitter';
import { PagerModule } from './modules/pager/pager.module';
import { ContactModule } from './modules/contact/contact.module';
import { InventoryModule } from './modules/inventory/inventory.module';
import { IconsModule } from './modules/icons/icons.module';
import { CacheModule } from '@nestjs/cache-manager';
import { cacheConfig } from './config/cache.config';

@Module({
  imports: [
    ConfigModule.forRoot({ isGlobal: true, cache: true }),
    CacheModule.registerAsync(cacheConfig()),
    MikroOrmModule.forRootAsync(dataBaseConfig),
    UserModule,
    UtilsModule,
    AuthModule,
    UploaderModule,
    AdminModule,
    ThrottlerModule.forRoot([
      {
        ttl: 60, // time window in seconds
        limit: 5, // max requests per window
      },
    ]),
    ScheduleModule.forRoot(),
    RestaurantsModule,
    FoodModule,
    CartModule,
    RolesModule,
    PaymentsModule,
    DeliveryModule,
    OrdersModule,
    CouponModule,
    ReviewModule,
    NotificationsModule,
    EventEmitterModule.forRoot(),
    PagerModule,
    ContactModule,
    InventoryModule,
    IconsModule,
  ],
  controllers: [],
  providers: [],
  // exports: [CacheService],
})
export class AppModule {}
