-
Notifications
You must be signed in to change notification settings - Fork 0
/
ormconfig.ts
35 lines (32 loc) · 1.06 KB
/
ormconfig.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
31
32
33
34
35
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import fs from 'fs';
import { join } from 'path';
import dotenv from 'dotenv';
dotenv.config();
const ormConfig: TypeOrmModuleOptions = {
type: 'postgres',
host: process.env.POSTGRES_HOST,
port: Number(process.env.POSTGRES_PORT),
username: process.env.POSTGRES_USERNAME,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DATABASE,
entities: [process.env.POSTGRES_ENTITIES],
synchronize: process.env.POSTGRES_SYNCHRONIZE === 'true',
logging: process.env.POSTGRES_LOGGING === 'true',
migrations: [process.env.POSTGRES_MIGRATIONS],
migrationsTableName: process.env.POSTGRES_MIGRATIONS_TABLE_NAME,
migrationsRun: process.env.POSTGRES_MIGRATIONS_RUN === 'true',
ssl:
process.env.NODE_ENV === 'development'
? false
: {
rejectUnauthorized: true,
ca: fs
.readFileSync(join(process.cwd(), 'certs/ca-certificate.crt'))
.toString(),
},
cli: {
migrationsDir: './src/migrations',
},
};
export default ormConfig;