app.module.ts48 lines, 1.2 KB
| 1 | import { Module } from '@nestjs/common'; |
| 2 | import { AppController } from './app.controller'; |
| 3 | import { AppService } from './app.service'; |
| 4 | import { AuthModule } from './auth/auth.module'; |
| 5 | import { PassportModule } from '@nestjs/passport'; |
| 6 | import { JwtModule } from '@nestjs/jwt'; |
| 7 | import { EventsModule } from './events/events.module'; |
| 8 | import { JwtStrategy } from 'apps/auth-service/src/jwt.strategy'; |
| 9 | import { TicketsModule } from './tickets/ticket.module'; |
| 10 | import { ThrottlerGuard, ThrottlerModule } from '@nestjs/throttler'; |
| 11 | import { ThrottlerStorageRedis } from './throttler-storage-redis'; |
| 12 | import { APP_GUARD } from '@nestjs/core'; |
| 13 | |
| 14 | @Module({ |
| 15 | imports: [ |
| 16 | PassportModule, |
| 17 | JwtModule.register({ |
| 18 | secret: process.env.JWT_SECRET || 'secret', |
| 19 | }), |
| 20 | ThrottlerModule.forRoot({ |
| 21 | throttlers: [ |
| 22 | { |
| 23 | name: 'default', |
| 24 | ttl: 60000, |
| 25 | limit: 10, |
| 26 | }, |
| 27 | ], |
| 28 | }), |
| 29 | AuthModule, |
| 30 | EventsModule, |
| 31 | TicketsModule, |
| 32 | ], |
| 33 | controllers: [AppController], |
| 34 | providers: [ |
| 35 | AppService, |
| 36 | JwtStrategy, |
| 37 | ThrottlerStorageRedis, |
| 38 | { |
| 39 | provide: 'ThrottlerStorage', |
| 40 | useClass: ThrottlerStorageRedis, |
| 41 | }, |
| 42 | { |
| 43 | provide: APP_GUARD, |
| 44 | useClass: ThrottlerGuard, |
| 45 | }, |
| 46 | ], |
| 47 | }) |
| 48 | export class AppModule {} |