Files
invest-mind-store/apps/api/src/database/database.config.ts
T
2025-11-17 17:53:31 +08:00

17 lines
632 B
TypeScript

import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import { ConfigService } from '@nestjs/config';
export const getDatabaseConfig = (
configService: ConfigService,
): TypeOrmModuleOptions => ({
type: 'postgres',
host: configService.get('DB_HOST', 'localhost'),
port: configService.get<number>('DB_PORT', 5432),
username: configService.get('DB_USER'),
password: configService.get('DB_PASSWORD'),
database: configService.get('DB_DATABASE'),
synchronize: configService.get('NODE_ENV') !== 'production',
autoLoadEntities: true,
logging: configService.get('NODE_ENV') === 'development',
});