26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
|
|
import { Module } from '@nestjs/common';
|
||
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||
|
|
import { BidItem } from '../bids/entities/bid-item.entity';
|
||
|
|
import { Keyword } from '../keywords/keyword.entity';
|
||
|
|
|
||
|
|
@Module({
|
||
|
|
imports: [
|
||
|
|
TypeOrmModule.forRootAsync({
|
||
|
|
imports: [ConfigModule],
|
||
|
|
inject: [ConfigService],
|
||
|
|
useFactory: (configService: ConfigService) => ({
|
||
|
|
type: configService.get<any>('DATABASE_TYPE', 'mariadb'),
|
||
|
|
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'),
|
||
|
|
entities: [BidItem, Keyword],
|
||
|
|
synchronize: configService.get<boolean>('DATABASE_SYNCHRONIZE', true),
|
||
|
|
}),
|
||
|
|
}),
|
||
|
|
],
|
||
|
|
})
|
||
|
|
export class DatabaseModule {}
|