import { MiddlewareConsumer , Module , NestModule } from '@nestjs/common' ; import { ConfigModule , ConfigService } from '@nestjs/config' ; import { APP_FILTER , RouterModule } from '@nestjs/core' ; import { ServeStaticModule } from '@nestjs/serve-static' ; import { TypeOrmModule } from '@nestjs/typeorm' ; import { AwsModule } from './aws' ; import { BaseModule } from './base' ; import { CommonModule , ExceptionsFilter , LoggerMiddleware } from './common' ; import { configuration } from './config' ; import { SampleModule as DebugSampleModule } from './debug' ; import { GqlModule } from './gql' ; import { SampleModule } from './sample' ; @ Module ( { imports : [ ConfigModule . forRoot ( { isGlobal : true , load : [ configuration ] , } ) , TypeOrmModule . forRootAsync ( { useFactory : ( config ) => ( { ... config . get ( 'db' ) , } ) , inject : [ ConfigService ] , } ) , ServeStaticModule . forRoot ( { rootPath : `${ __dirname }/../public` , renderPath : '/' , } ) , CommonModule , BaseModule , SampleModule , GqlModule , DebugSampleModule , AwsModule , RouterModule . register ( [ { path : 'aws' , module : AwsModule , } , { path : 'test' , module : SampleModule , } , { path : 'test' , module : DebugSampleModule , } ] ) , ] , providers : [ { provide : APP_FILTER , useClass : ExceptionsFilter } , ] , } ) export class AppModule implements NestModule { public configure ( consumer ) { consumer . apply ( LoggerMiddleware ) . forRoutes ( '*' ) ; } }