NestJS-Boilerplate/orm.config.ts
2024-06-10 10:21:25 -03:00

18 lines
616 B
TypeScript

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('DATABASE_HOST') || 'localhost',
port: configService.get('DATABASE_PORT') || 5432,
username: configService.get('DATABASE_USERNAME') || 'postgres',
password: configService.get('DATABASE_PASSWORD') || '1234',
database: configService.get('DATABASE_NAME') || 'boilerplatenestjs',
entities: ['./src/**/*.entity.ts'],
migrations: ['migrations/*-migrations.ts'],
});