All files / config database.config.ts

0% Statements 0/3
0% Branches 0/2
0% Functions 0/1
0% Lines 0/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18                                   
import { ConfigService } from '@nestjs/config';
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
 
export const databaseConfig = (configService: ConfigService): TypeOrmModuleOptions => ({
  type: 'postgres',
  host: configService.get<string>('database.host'),
  port: configService.get<number>('database.port'),
  database: configService.get<string>('database.name'),
  username: configService.get<string>('database.user'),
  password: configService.get<string>('database.password'),
  entities: [__dirname + '/../**/*.entity{.ts,.js}'],
  synchronize: false, // NEVER true in production - use migrations
  logging: configService.get<string>('nodeEnv') === 'development',
  ssl: configService.get<string>('nodeEnv') === 'production'
    ? { rejectUnauthorized: false }
    : false,
});