Repository navigation
Expand file tree
/
Copy pathapp.module.ts
More file actions
37 lines (37 loc) · 1.49 KB
/
Copy pathapp.module.ts
File metadata and controls
37 lines (37 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { ThrottlerGuard, ThrottlerModule } from '@nestjs/throttler';
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { APP_FILTER, APP_GUARD } from '@nestjs/core';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ProductsModule } from './products/products.module';
import { CustomersModule } from './customers/customers.module';
import { OrdersModule } from './orders/orders.module';
import { LoggerMiddleware } from './common/middleware/logger/logger.middleware';
import { DatabaseExceptionFilter } from './common/filters/database-exception/database-exception.filter';
import { AuthModule } from './auth/auth.module';
import { UsersModule } from './users/users.module';
import { databaseOptions } from './database/data-source';
import { HealthController } from './health.controller';
@Module({
imports: [
ThrottlerModule.forRoot([{ ttl: 60000, limit: 120 }]),
TypeOrmModule.forRootAsync({ useFactory: databaseOptions }),
ProductsModule,
CustomersModule,
OrdersModule,
AuthModule,
UsersModule,
],
controllers: [AppController, HealthController],
providers: [
AppService,
{ provide: APP_GUARD, useClass: ThrottlerGuard },
{ provide: APP_FILTER, useClass: DatabaseExceptionFilter },
],
})
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer.apply(LoggerMiddleware).forRoutes('{*path}');
}
}