import { TypeOrmModuleOptions } from '@nestjs/typeorm' ; import config from 'config' ; const settings = config . get ( 'DB_SETTINGS' ) ; export function getOrmConfig ( ) { let ormConfig ; if ( process . env . NODE_ENV !== 'test' ) { ormConfig = { type : 'postgres' , ... settings , database : `${ settings . database }_${ process . env . NODE_ENV }` , entities : [ __dirname + '../../**/*.entity{.ts,.js}' ] , migrations : [ __dirname + '/migrations/**/*{.ts,.js}' ] , migrationsRun : false , maxQueryExecutionTime : 0.1 , synchronize : false , cli : { migrationsDir : __dirname + '/migrations/**/*{.ts,.js}' , } , } ; } else { ormConfig = { type : 'sqlite' , database : ':memory:' , entities : [ __dirname + '../../**/*.entity{.ts,.js}' ] , migrations : [ __dirname + '/migrations/**/*{.ts,.js}' ] , migrationsRun : true , keepConnectionAlive : true , synchronize : true , cli : { migrationsDir : __dirname + '/migrations/**/*{.ts,.js}' , } , } ; } return ormConfig ; }