import { Module, NestModule } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { ConfigModule, ConfigService } from '@nestjs/config'; import config from './config/config'; import { MailModule } from './mail/mail.module'; import { RedisModule } from './redis/redis.module'; import { OpenTelemetryModule } from 'nestjs-otel'; import databaseConfig from './config/database.config'; import { TypeOrmModule } from '@nestjs/typeorm'; import { TypeOrmConfigService } from './database/database-config.service'; import { AuthModule } from './auth/auth.module'; import { UserModule } from './user/user.module'; import { ServeStaticModule } from '@nestjs/serve-static'; import { join } from 'path'; import { AuthMiddleware } from './auth/middleware/auth.middleware'; import { ClsModule } from 'nestjs-cls'; @Module({ imports: [ OpenTelemetryModule.forRoot({ metrics: { apiMetrics: { enable: true, ignoreRoutes: [ '/favicon.ico', '/OidcServiceWorker.js', '/swagger', '/swagger-json', '/swagger-yaml', '/swagger/(.*)', '/metrics', '/interaction/(.*}', ], ignoreUndefinedRoutes: true, }, }, }), ConfigModule.forRoot({ cache: true, isGlobal: true, load: [config, databaseConfig], }), TypeOrmModule.forRootAsync({ imports: [ConfigModule], useClass: TypeOrmConfigService, inject: [ConfigService], }), ServeStaticModule.forRoot({ serveRoot: '/assets', rootPath: join(__dirname, '..', 'assets'), }), ClsModule.forRoot({ global: true, middleware: { mount: false }, }), MailModule, RedisModule, UserModule, AuthModule, ], controllers: [AppController], providers: [AppService], }) export class AppModule implements NestModule { configure(consumer: import('@nestjs/common').MiddlewareConsumer) { consumer.apply(AuthMiddleware).forRoutes('*'); } }