57 lines
2.1 KiB
TypeScript
57 lines
2.1 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
import { AppController } from './app.controller';
|
|
import { AppService } from './app.service';
|
|
import databaseConfig from './config/database.config';
|
|
import jwtConfig from './config/jwt.config';
|
|
import { User } from './entities/user.entity';
|
|
import { Case } from './entities/case.entity';
|
|
import { Service } from './entities/service.entity';
|
|
import { Booking } from './entities/booking.entity';
|
|
import { AuthModule } from './auth/auth.module';
|
|
import { UserModule } from './user/user.module';
|
|
import { CaseModule } from './case/case.module';
|
|
import { ServiceModule } from './service/service.module';
|
|
import { BookingModule } from './booking/booking.module';
|
|
import { DatabaseSeederService } from './database/database-seeder.service';
|
|
|
|
@Module({
|
|
imports: [
|
|
ConfigModule.forRoot({
|
|
isGlobal: true,
|
|
load: [databaseConfig, jwtConfig],
|
|
envFilePath: '.env',
|
|
}),
|
|
TypeOrmModule.forRootAsync({
|
|
imports: [ConfigModule],
|
|
useFactory: (configService: ConfigService) => ({
|
|
type: 'mysql',
|
|
host: configService.get('database.host'),
|
|
port: configService.get('database.port'),
|
|
username: configService.get('database.username'),
|
|
password: configService.get('database.password'),
|
|
database: configService.get('database.database'),
|
|
entities: [User, Case, Service, Booking],
|
|
synchronize: configService.get('database.synchronize'),
|
|
logging: configService.get('database.logging'),
|
|
charset: configService.get('database.charset'),
|
|
timezone: configService.get('database.timezone'),
|
|
retryAttempts: 3, // 减少重试次数
|
|
retryDelay: 1000, // 重试延迟
|
|
autoLoadEntities: true,
|
|
}),
|
|
inject: [ConfigService],
|
|
}),
|
|
TypeOrmModule.forFeature([User]),
|
|
AuthModule,
|
|
UserModule,
|
|
CaseModule,
|
|
ServiceModule,
|
|
BookingModule,
|
|
],
|
|
controllers: [AppController],
|
|
providers: [AppService, DatabaseSeederService],
|
|
})
|
|
export class AppModule {}
|