File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed
app/persistence/postgreSQL Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -97,10 +97,26 @@ export class PgService {
9797 * @memberof PgService
9898 */
9999 getUserModel ( attributes , options ) {
100- const sequelize = new Sequelize (
101- `postgres://${ this . pgconfig . user } :${ this . pgconfig . password } @${ this . pgconfig . host } :${ this . pgconfig . port } /${ this . pgconfig . database } ` ,
102- { logging : false }
103- ) ;
100+
101+ // Add SSL option for PostGresql- Issue #404
102+ const isPostgresSslEnabled = process . env . DATABASE_SSL_ENABLED || false ;
103+
104+ if ( isPostgresSslEnabled ) {
105+ logger . info ( 'SSL to Postgresql enabled: set dialect SSL option' ) ;
106+ const sequelize = new Sequelize (
107+ `postgres://${ this . pgconfig . user } :${ this . pgconfig . password } @${ this . pgconfig . host } :${ this . pgconfig . port } /${ this . pgconfig . database } ` ,
108+ { logging : false , dialectOptions : { ssl : true , } , }
109+ ) ;
110+ } else {
111+ logger . info ( 'SSL to Postgresql disabled: dialect options not set' ) ;
112+ const sequelize = new Sequelize (
113+ `postgres://${ this . pgconfig . user } :${ this . pgconfig . password } @${ this . pgconfig . host } :${ this . pgconfig . port } /${ this . pgconfig . database } ` ,
114+ { logging : false }
115+ ) ;
116+
117+ }
118+
119+
104120 this . userModel = sequelize . define ( 'users' , attributes , options ) ;
105121 return this . userModel ;
106122 }
You can’t perform that action at this time.
0 commit comments