import { DataSource } from 'typeorm'; import { ConfigService } from '@nestjs/config'; import { config } from 'dotenv'; config(); const configService = new ConfigService(); export default new DataSource({ type: 'postgres', host: configService.get('DB_HOST') || 'localhost', port: configService.get('DB_PORT') || 5432, username: configService.get('DB_USERNAME') || 'postgres', password: configService.get('DB_PASSWORD') || 'postgres', database: configService.get('DB_NAME') || 'realtime_chat_db', entities: [__dirname + '/entities/**/*.entity{.ts,.js}'], migrations: [__dirname + '/migrations/**/*{.ts,.js}'], synchronize: false, logging: configService.get('NODE_ENV') === 'development', ssl: configService.get('NODE_ENV') === 'production' ? { rejectUnauthorized: false } : false, });