Created
December 2, 2023 11:40
-
-
Save GoodnessEzeokafor/51fe463ecaa079179862b6a2f17ffc65 to your computer and use it in GitHub Desktop.
Connecting to postgresql db with ssl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DataSource } from 'typeorm'; | |
import { ConfigService } from '@nestjs/config'; | |
import { config } from 'dotenv'; | |
import models from '../../models'; | |
config(); | |
const configService = new ConfigService(); | |
export default new DataSource({ | |
type: 'postgres', | |
host: configService.get('DB_HOST'), | |
port: configService.get('DB_PORT'), | |
username: configService.get('DB_USER'), | |
password: configService.get('DB_PASSWORD'), | |
database: configService.get('DB_NAME'), | |
entities: models, | |
migrations: [__dirname + '/migrations/staging/*.ts'], | |
ssl: { | |
rejectUnauthorized: false, | |
ca: configService.get('POSTGRES_SQL_CERT').replace(/[\r\n]/gm, ''), | |
}, | |
synchronize: false, | |
migrationsRun: true, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment