| 1 | import { RedisModule } from '@liaoliaots/nestjs-redis'; |
| 2 | import { MiddlewareConsumer, Module |
| 3 | import { ConfigModule, ConfigService |
| 4 | |
| 5 | import { AppController } |
| 6 | import { AppService } |
| 7 | import { AuthMiddleware } |
| 8 | import { AirlinesModule } |
| 9 | import { AirportsModule } |
| 10 | import { AuthModule } |
| 11 | import { FlightModule } |
| 12 | import { FlightsModule } |
| 13 | import { AlertsModule } |
| 14 | |
| 15 | @Module({ |
| 16 | imports: [ |
| 17 | ConfigModule.forRoot({ |
| 18 | RedisModule.forRootAsync({ |
| 19 | useFactory: (configService: |
| 20 | const redisUrl = |
| 21 | configService.get('REDIS_URL |
| 22 | ); |
| 23 | return { |
| 24 | config: { |
| 25 | host: redisUrl.hostname |
| 26 | port: parseInt(redisUrl |
| 27 | password: redisUrl.password |
| 28 | db: redisUrl.pathname |
| 29 | ? parseInt(redisUrl. |
| 30 | : 0, |
| 31 | family: 0, |
| 32 | }, |
| 33 | }; |
| 34 | }, |
| 35 | inject: [ConfigService], |
| 36 | }), |
| 37 | AuthModule, |
| 38 | AirportsModule, |
| 39 | AirlinesModule, |
| 40 | FlightsModule, |
| 41 | FlightModule, |
| 42 | AlertsModule, |
| 43 | ], |
| 44 | controllers: [AppController], |
| 45 | providers: [AppService], |
| 46 | }) |
| 47 | export class AppModule |
| 48 | configure(consumer: |
| 49 | consumer |
| 50 | .apply(AuthMiddleware) |
| 51 | .exclude('/v(.*)/auth/(login|register)') |
| 52 | .exclude('/v(.*)/airports') |
| 53 | .exclude('/v(.*)/airlines') |
| 54 | .exclude('/static/(.*)') |
| 55 | .exclude(`/alerts/(.*)`) |
| 56 | .forRoutes('*') |
| 57 | } |
| 58 | } |