31 lines
915 B
TypeScript
31 lines
915 B
TypeScript
|
|
import { Module } from '@nestjs/common';
|
||
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||
|
|
import { Password } from 'src/admins/entities/password.entity';
|
||
|
|
import { Admin } from 'src/admins/entities/admin.entity';
|
||
|
|
|
||
|
|
@Module({
|
||
|
|
imports: [
|
||
|
|
TypeOrmModule.forRootAsync({
|
||
|
|
imports: [ConfigModule],
|
||
|
|
inject: [ConfigService],
|
||
|
|
useFactory: (configService: ConfigService) => ({
|
||
|
|
type: 'postgres',
|
||
|
|
host: configService.get('DB_HOST'),
|
||
|
|
port: configService.get('DB_PORT'),
|
||
|
|
username: configService.get('DB_USERNAME'),
|
||
|
|
password: configService.get('DB_PASSWORD'),
|
||
|
|
database: configService.get('DB_NAME'),
|
||
|
|
synchronize: false,
|
||
|
|
logging: false,
|
||
|
|
subscribers: [],
|
||
|
|
entities: [
|
||
|
|
Admin,
|
||
|
|
Password,
|
||
|
|
]
|
||
|
|
}),
|
||
|
|
}),
|
||
|
|
],
|
||
|
|
})
|
||
|
|
export class DatabaseModule {}
|