oa_based/src/app.module.ts

84 lines
3.0 KiB
TypeScript
Raw Normal View History

2024-02-28 17:02:46 +08:00
import { ClassSerializerInterceptor, Module } from '@nestjs/common';
2024-02-28 08:32:35 +08:00
2024-02-28 17:02:46 +08:00
import { ConfigModule } from '@nestjs/config';
import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
2024-02-28 08:32:35 +08:00
2024-02-28 17:02:46 +08:00
import config from '~/config';
import { SharedModule } from '~/shared/shared.module';
2024-02-28 08:32:35 +08:00
2024-02-28 17:02:46 +08:00
import { AllExceptionsFilter } from './common/filters/any-exception.filter';
2024-02-28 08:32:35 +08:00
2024-02-28 17:02:46 +08:00
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';
2024-02-28 08:32:35 +08:00
2024-02-28 17:02:46 +08:00
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';
2024-02-29 10:32:37 +08:00
import { MaterialsInventoryModule } from './modules/materials_inventory/materials_inventory.module';
2024-03-04 16:34:54 +08:00
import { CompanyModule } from './modules/company/company.module';
2024-02-28 08:32:35 +08:00
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
expandVariables: true,
// 指定多个 env 文件时,第一个优先级最高
envFilePath: ['.env.local', `.env.${process.env.NODE_ENV}`, '.env'],
2024-02-29 09:29:03 +08:00
load: [...Object.values(config)]
2024-02-28 08:32:35 +08:00
}),
SharedModule,
DatabaseModule,
AuthModule,
SystemModule,
TasksModule.forRoot(),
ToolsModule,
SocketModule,
HealthModule,
SseModule,
NetdiskModule,
// biz
// end biz
TodoModule,
2024-02-28 17:02:46 +08:00
ContractModule,
2024-02-29 10:32:37 +08:00
VehicleUsageModule,
2024-03-04 16:34:54 +08:00
MaterialsInventoryModule,
CompanyModule
2024-02-28 08:32:35 +08:00
],
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]
2024-02-28 08:32:35 +08:00
})
export class AppModule {}