mirror of
https://github.com/BreizhHardware/Jellystat.git
synced 2026-01-18 16:27:20 +01:00
POSTGRES_SSL_ENABLED environment variable
This commit is contained in:
@@ -12,7 +12,9 @@ const client = new Client({
|
||||
user: _POSTGRES_USER,
|
||||
password: _POSTGRES_PASSWORD,
|
||||
port: _POSTGRES_PORT,
|
||||
ssl: { rejectUnauthorized: _POSTGRES_SSL_REJECT_UNAUTHORIZED }
|
||||
...(process.env.POSTGRES_SSL_ENABLED === "true"
|
||||
? { ssl: { rejectUnauthorized: _POSTGRES_SSL_REJECT_UNAUTHORIZED } }
|
||||
: {})
|
||||
});
|
||||
|
||||
const createDatabase = async () => {
|
||||
|
||||
@@ -23,7 +23,9 @@ const pool = new Pool({
|
||||
max: 20, // Maximum number of connections in the pool
|
||||
idleTimeoutMillis: 30000, // Close idle clients after 30 seconds
|
||||
connectionTimeoutMillis: 2000, // Return an error after 2 seconds if connection could not be established
|
||||
ssl: { rejectUnauthorized: _POSTGRES_SSL_REJECT_UNAUTHORIZED } // Enable SSL without strict cert validation
|
||||
...(process.env.POSTGRES_SSL_ENABLED === "true"
|
||||
? { ssl: { rejectUnauthorized: _POSTGRES_SSL_REJECT_UNAUTHORIZED } }
|
||||
: {})
|
||||
});
|
||||
|
||||
pool.on("error", (err, client) => {
|
||||
|
||||
@@ -12,7 +12,9 @@ module.exports = {
|
||||
port:process.env.POSTGRES_PORT,
|
||||
database: process.env.POSTGRES_DB || 'jfstat',
|
||||
createDatabase: true,
|
||||
ssl: { rejectUnauthorized: process.env.POSTGRES_SSL_REJECT_UNAUTHORIZED === undefined ? true : process.env.POSTGRES_SSL_REJECT_UNAUTHORIZED === "true" }
|
||||
...(process.env.POSTGRES_SSL_ENABLED === "true"
|
||||
? { ssl: { rejectUnauthorized: process.env.POSTGRES_SSL_REJECT_UNAUTHORIZED === undefined ? true : process.env.POSTGRES_SSL_REJECT_UNAUTHORIZED === "true" } }
|
||||
: {})
|
||||
},
|
||||
migrations: {
|
||||
directory: __dirname + '/migrations',
|
||||
@@ -40,7 +42,9 @@ module.exports = {
|
||||
port:process.env.POSTGRES_PORT,
|
||||
database: process.env.POSTGRES_DB || 'jfstat',
|
||||
createDatabase: true,
|
||||
ssl: { rejectUnauthorized: process.env.POSTGRES_SSL_REJECT_UNAUTHORIZED === undefined ? true : process.env.POSTGRES_SSL_REJECT_UNAUTHORIZED === "true" }
|
||||
...(process.env.POSTGRES_SSL_ENABLED === "true"
|
||||
? { ssl: { rejectUnauthorized: process.env.POSTGRES_SSL_REJECT_UNAUTHORIZED === undefined ? true : process.env.POSTGRES_SSL_REJECT_UNAUTHORIZED === "true" } }
|
||||
: {})
|
||||
},
|
||||
migrations: {
|
||||
directory: __dirname + '/migrations',
|
||||
|
||||
@@ -54,7 +54,9 @@ async function restore(file, refLog) {
|
||||
host: postgresIp,
|
||||
port: postgresPort,
|
||||
database: postgresDatabase,
|
||||
ssl: { rejectUnauthorized: postgresSslRejectUnauthorized },
|
||||
...(process.env.POSTGRES_SSL_ENABLED === "true"
|
||||
? { ssl: { rejectUnauthorized: postgresSslRejectUnauthorized } }
|
||||
: {}),
|
||||
});
|
||||
|
||||
const backupPath = file;
|
||||
|
||||
Reference in New Issue
Block a user