@@ -68,32 +68,25 @@ const configure = () => {
6868 const envPostgresName = process . env . DB_POSTGRES_NAME || null ;
6969 const envPostgresSslMode = process . env . DB_POSTGRES_SSL_MODE || null ;
7070 if ( envPostgresHost && envPostgresUser && envPostgresName ) {
71- // we have enough postgres creds to go with postgres
72- logger . info ( "Using Postgres configuration" ) ;
73-
74- // knex does not handle ssl enablement other than in the connectionString, so let's use it
75- // this prevents the serivce from starting on databases with self signed certificates
76- // cf https://knexjs.org/guide/#configuration-options
77- port = process . env . DB_POSTGRES_PORT || 5432
78- connectionString = `postgresql://${ envPostgresUser } :${ process . env . DB_POSTGRES_PASSWORD } @${ port } /${ envPostgresName } `
79- if ( envPostgresSslMode ) {
80- connectionString = connectionString + `?ssl=true&sslmode=${ envPostgresSslMode } `
81- }
82- instance = {
83- database : {
84- connectionString : connectionString ,
85- engine : postgresEngine ,
86- host : envPostgresHost ,
87- port : port ,
88- user : envPostgresUser ,
89- password : process . env . DB_POSTGRES_PASSWORD ,
90- name : envPostgresName ,
91- ssl : envPostgresSslMode ? { rejectUnauthorized : false } : false
92- } ,
93- keys : getKeys ( ) ,
94- } ;
95- return ;
96- }
71+ // we have enough postgres creds to go with postgres
72+ logger . info ( "Using Postgres configuration" ) ;
73+ instance = {
74+ database : {
75+ engine : postgresEngine ,
76+ host : envPostgresHost ,
77+ port : port ,
78+ user : envPostgresUser ,
79+ password : process . env . DB_POSTGRES_PASSWORD ,
80+ name : envPostgresName ,
81+ ssl : envPostgresSslMode ? {
82+ sslmode : envPostgresSslMode ,
83+ rejectUnauthorized : envPostgresSslMode === "verify-full" ? true : false ,
84+ } : false
85+ } ,
86+ keys : getKeys ( ) ,
87+ } ;
88+ return ;
89+ }
9790
9891 const envSqliteFile = process . env . DB_SQLITE_FILE || "/data/database.sqlite" ;
9992 logger . info ( `Using Sqlite: ${ envSqliteFile } ` ) ;
0 commit comments