import { ClassSerializerInterceptor, Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core'; import config from '~/config'; import { SharedModule } from '~/shared/shared.module'; import { AllExceptionsFilter } from './common/filters/any-exception.filter'; import { IdempotenceInterceptor } from './common/interceptors/idempotence.interceptor'; import { TimeoutInterceptor } from './common/interceptors/timeout.interceptor'; import { TransformInterceptor } from './common/interceptors/transform.interceptor'; import { AuthModule } from './modules/auth/auth.module'; import { JwtAuthGuard } from './modules/auth/guards/jwt-auth.guard'; import { RbacGuard } from './modules/auth/guards/rbac.guard'; import { HealthModule } from './modules/health/health.module'; import { NetdiskModule } from './modules/netdisk/netdisk.module'; import { SseModule } from './modules/sse/sse.module'; import { SystemModule } from './modules/system/system.module'; import { TasksModule } from './modules/tasks/tasks.module'; import { TodoModule } from './modules/todo/todo.module'; import { ToolsModule } from './modules/tools/tools.module'; import { DatabaseModule } from './shared/database/database.module'; import { SocketModule } from './socket/socket.module'; import { ContractModule } from './modules/contract/contract.module'; import { VehicleUsageModule } from './modules/vehicle-usage/vehicle-usage.module'; import { VehicleUsageController } from './modules/vehicle-usage/vehicle-usage.controller'; import { VehicleUsageService } from './modules/vehicle-usage/vehicle-usage.service'; import { MaterialsInventoryModule } from './modules/materials_inventory/materials_inventory.module'; import { CompanyModule } from './modules/company/company.module'; import { ProductModule } from './modules/product/product.module'; @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true, expandVariables: true, // 指定多个 env 文件时,第一个优先级最高 envFilePath: ['.env.local', `.env.${process.env.NODE_ENV}`, '.env'], load: [...Object.values(config)] }), SharedModule, DatabaseModule, AuthModule, SystemModule, TasksModule.forRoot(), ToolsModule, SocketModule, HealthModule, SseModule, NetdiskModule, // biz // end biz TodoModule, ContractModule, VehicleUsageModule, MaterialsInventoryModule, CompanyModule, ProductModule ], providers: [ { provide: APP_FILTER, useClass: AllExceptionsFilter }, { provide: APP_INTERCEPTOR, useClass: ClassSerializerInterceptor }, { provide: APP_INTERCEPTOR, useClass: TransformInterceptor }, { provide: APP_INTERCEPTOR, useFactory: () => new TimeoutInterceptor(15 * 1000) }, { provide: APP_INTERCEPTOR, useClass: IdempotenceInterceptor }, { provide: APP_GUARD, useClass: JwtAuthGuard }, { provide: APP_GUARD, useClass: RbacGuard }, VehicleUsageService ], controllers: [VehicleUsageController] }) export class AppModule {}