File size: 1,219 Bytes
15f4599
c114c72
 
3cdf53d
 
 
 
15f4599
c114c72
 
8b7e5fc
88f437e
 
3cdf53d
 
 
 
 
 
 
 
 
c114c72
8b7e5fc
3cdf53d
88f437e
 
 
15f4599
 
 
c114c72
15f4599
 
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
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { AppController } from './app.controller.js';
import { AppService } from './app.service.js';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { configuration } from './config/config.js';
import { DatabaseConfigService } from './config/database.js';
import { AppLoggerMiddleware } from './common/middlewares/app-logger.middleware.js';
import { DeviceInfoMiddleware } from './common/middlewares/device-info.middleware.js';
import { UserModule } from './modules/user/user.module.js';
import { BranchModule } from './modules/branch/branch.module.js';

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      load: [configuration],
    }),
    TypeOrmModule.forRootAsync({
      imports: [ConfigModule],
      useClass: DatabaseConfigService,
    }),
    UserModule,
    BranchModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer): void {
    consumer.apply(AppLoggerMiddleware).forRoutes('*');
    consumer.apply(DeviceInfoMiddleware).forRoutes('*');
  }
}