import { Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { ThrottlerModule } from '@nestjs/throttler'; import { ScheduleModule } from '@nestjs/schedule'; import { BullModule } from '@nestjs/bullmq'; import { LoggerModule } from 'nestjs-pino'; import { HealthController } from './health/health.controller'; import { AuthModule } from './auth/auth.module'; import { EventsModule } from './events/events.module'; function parseRedisConnection(redisUrl: string | undefined) { if (!redisUrl) { return { host: 'localhost', port: 6379 }; } const url = new URL(redisUrl); return { host: url.hostname, port: Number(url.port || 6379), password: url.password || undefined, }; } @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true }), LoggerModule.forRoot(), ThrottlerModule.forRoot([{ ttl: 60000, limit: 100 }]), ScheduleModule.forRoot(), BullModule.forRoot({ connection: parseRedisConnection(process.env.REDIS_URL) }), AuthModule, EventsModule, ], controllers: [HealthController], }) export class AppModule {}