import { Module } from '@nestjs/common' ; import { TypeOrmModule } from '@nestjs/typeorm' ; import { ConfigModule , ConfigService } from '@nestjs/config' ; import { SnakeNamingStrategy } from 'typeorm-naming-strategies' ; @ Module ( { imports : [ TypeOrmModule . forRootAsync ( { imports : [ ConfigModule ] , inject : [ ConfigService ] , useFactory : ( configService ) => ( { type : 'postgres' , host : configService . get ( 'POSTGRES_HOST' ) , port : configService . get ( 'POSTGRES_PORT' ) , username : configService . get ( 'POSTGRES_USER' ) , password : configService . get ( 'POSTGRES_PASSWORD' ) , database : configService . get ( 'POSTGRES_DB' ) , entities : [ __dirname + '/../**/*.entity.ts' , __dirname + '/../**/*.entity.js' , ] , namingStrategy : new SnakeNamingStrategy ( ) , synchronize : false , logging : true , } ) , } ) , ] , } ) export class DatabaseModule { }