waterwolf-auth/apps/backend/src/app.module.ts

84 lines
2.7 KiB
TypeScript

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/service/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';
import { BullModule } from '@nestjs/bullmq';
import { BullConfigService } from './redis/service/bull-config.service';
import { RedisService } from './redis/service/redis.service';
import { OrganizationModule } from './organization/organization.module';
import { ClientModule } from './client/client.module';
import { ViewModule } from './view/view.module';
@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],
envFilePath: ['.env', '.env.local', '../../.env', '../../.env.local'],
}),
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
useClass: TypeOrmConfigService,
inject: [ConfigService],
}),
ServeStaticModule.forRoot({
serveRoot: '/assets',
rootPath: join(__dirname, '..', 'assets'),
}),
ClsModule.forRoot({
global: true,
middleware: { mount: false },
}),
RedisModule,
BullModule.forRootAsync({
imports: [RedisModule],
useClass: BullConfigService,
inject: [RedisService],
}),
MailModule,
UserModule,
AuthModule,
OrganizationModule,
ClientModule,
ViewModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule implements NestModule {
configure(consumer: import('@nestjs/common').MiddlewareConsumer) {
consumer.apply(AuthMiddleware).forRoutes('*');
}
}