2026-01-09 23:18:52 +08:00
|
|
|
import { Module } from '@nestjs/common';
|
|
|
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
|
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
|
|
|
|
|
|
|
|
@Module({
|
|
|
|
|
imports: [
|
|
|
|
|
TypeOrmModule.forRootAsync({
|
|
|
|
|
imports: [ConfigModule],
|
|
|
|
|
inject: [ConfigService],
|
|
|
|
|
useFactory: (configService: ConfigService) => ({
|
2026-01-14 22:26:32 +08:00
|
|
|
type:
|
|
|
|
|
(configService.get<string>('DATABASE_TYPE', 'mariadb') as
|
|
|
|
|
| 'mariadb'
|
|
|
|
|
| 'mysql'
|
|
|
|
|
| 'postgres') || 'mariadb',
|
2026-01-09 23:18:52 +08:00
|
|
|
host: configService.get<string>('DATABASE_HOST', 'localhost'),
|
|
|
|
|
port: configService.get<number>('DATABASE_PORT', 3306),
|
|
|
|
|
username: configService.get<string>('DATABASE_USERNAME', 'root'),
|
|
|
|
|
password: configService.get<string>('DATABASE_PASSWORD', 'root'),
|
|
|
|
|
database: configService.get<string>('DATABASE_NAME', 'bidding'),
|
2026-01-15 00:35:19 +08:00
|
|
|
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
|
2026-01-14 20:58:07 +08:00
|
|
|
synchronize: false,
|
2026-01-15 16:17:41 +08:00
|
|
|
timezone: '+08:00',
|
2026-01-09 23:18:52 +08:00
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
export class DatabaseModule {}
|