-
Notifications
You must be signed in to change notification settings - Fork 1
/
data-source.ts
30 lines (25 loc) · 964 Bytes
/
data-source.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import 'reflect-metadata';
import { DataSource, DataSourceOptions } from 'typeorm';
import { config } from 'dotenv';
import { ConfigService } from '@nestjs/config';
config();
const configService = new ConfigService();
export const AppDataSource = new DataSource({
type: (configService.get<string>('DATABASE_CONNECTION') as any) || 'postgres',
host: configService.get<string>('DATABASE_HOST'),
port: configService.get<number>('DATABASE_PORT'),
username: configService.get<string>('DATABASE_USERNAME'),
password: configService.get<string>('DATABASE_PASSWORD'),
database: configService.get<string>('DATABASE_DB_NAME'),
dropSchema: false,
keepConnectionAlive: true,
logging: 'all',
logger: 'advanced-console',
migrations: ['src/database/migrations/*.ts'],
entities: [],
// ssl: {
// require: false,
// rejectUnauthorized: false,
// },
} as DataSourceOptions);
// console.log(AppDataSource);