import { Module } from '@nestjs/common'; import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { TypeOrmModule } from '@nestjs/typeorm'; import { ScheduleModule } from '@nestjs/schedule'; import { MapsModule } from './maps/maps.module'; import { GeocodingModule } from './geocoding/geocoding.module'; import { AuthModule } from './auth/auth.module'; import { ThrottlerModule } from '@nestjs/throttler'; import { UsageModule } from './usage/usage.module'; import { BillingModule } from './billing/billing.module'; import { MailModule } from './common/mail.module'; import { WeatherModule } from './weather/weather.module'; import { TacticalModule } from './tactical/tactical.module'; import { UsageInterceptor } from './usage/usage.interceptor'; @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true, }), ScheduleModule.forRoot(), TypeOrmModule.forRootAsync({ imports: [ConfigModule], inject: [ConfigService], useFactory: (config: ConfigService) => ({ type: 'postgres', url: config.get('DATABASE_URL'), autoLoadEntities: true, synchronize: false, // Production-ready: disabled to prevent data loss. Use migrations for schema changes. }), }), ThrottlerModule.forRoot([{ ttl: 60000, limit: 10, // Default fallback limit }]), AuthModule, MapsModule, GeocodingModule, UsageModule, BillingModule, MailModule, WeatherModule, TacticalModule, ], controllers: [], providers: [ { provide: APP_INTERCEPTOR, useClass: UsageInterceptor, }, ], }) export class AppModule {}