File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed
app/persistence/postgreSQL Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -97,10 +97,27 @@ 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+ let sequelize ;
104+
105+ if ( isPostgresSslEnabled ) {
106+ logger . info ( 'SSL to Postgresql enabled: set dialect SSL option' ) ;
107+ sequelize = new Sequelize (
108+ `postgres://${ this . pgconfig . user } :${ this . pgconfig . password } @${ this . pgconfig . host } :${ this . pgconfig . port } /${ this . pgconfig . database } ` ,
109+ { logging : false , dialectOptions : { ssl : true , } , }
110+ ) ;
111+ } else {
112+ logger . info ( 'SSL to Postgresql disabled: dialect options not set' ) ;
113+ sequelize = new Sequelize (
114+ `postgres://${ this . pgconfig . user } :${ this . pgconfig . password } @${ this . pgconfig . host } :${ this . pgconfig . port } /${ this . pgconfig . database } ` ,
115+ { logging : false }
116+ ) ;
117+
118+ }
119+
120+
104121 this . userModel = sequelize . define ( 'users' , attributes , options ) ;
105122 return this . userModel ;
106123 }
You can’t perform that action at this time.
0 commit comments