mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2025-12-24 02:39:18 -05:00
feat(db): add flag to toggle TLS for Postgres
This commit is contained in:
@@ -31,6 +31,22 @@ const prodConfig: DataSourceOptions = {
|
||||
};
|
||||
|
||||
const postgresDevConfig: DataSourceOptions = {
|
||||
type: 'postgres',
|
||||
name: 'pgdb',
|
||||
host: process.env.DB_HOST,
|
||||
port: parseInt(process.env.DB_PORT ?? '5432'),
|
||||
username: process.env.DB_USER,
|
||||
password: process.env.DB_PASS,
|
||||
database: process.env.DB_NAME ?? 'jellyseerr',
|
||||
synchronize: true,
|
||||
migrationsRun: false,
|
||||
logging: false,
|
||||
entities: ['server/entity/**/*.ts'],
|
||||
migrations: ['server/migration/**/*.ts'],
|
||||
subscribers: ['server/subscriber/**/*.ts'],
|
||||
};
|
||||
|
||||
const postgresDevConfigSSL: DataSourceOptions = {
|
||||
type: 'postgres',
|
||||
name: 'pgdb',
|
||||
host: process.env.DB_HOST,
|
||||
@@ -53,6 +69,22 @@ const postgresDevConfig: DataSourceOptions = {
|
||||
};
|
||||
|
||||
const postgresProdConfig: DataSourceOptions = {
|
||||
type: 'postgres',
|
||||
name: 'pgdb',
|
||||
host: process.env.DB_HOST,
|
||||
port: parseInt(process.env.DB_PORT ?? '5432'),
|
||||
username: process.env.DB_USER,
|
||||
password: process.env.DB_PASS,
|
||||
database: process.env.DB_NAME ?? 'jellyseerr',
|
||||
synchronize: false,
|
||||
migrationsRun: false,
|
||||
logging: false,
|
||||
entities: ['dist/entity/**/*.js'],
|
||||
migrations: ['dist/migration/**/*.js'],
|
||||
subscribers: ['dist/subscriber/**/*.js'],
|
||||
};
|
||||
|
||||
const postgresProdConfigSSL: DataSourceOptions = {
|
||||
type: 'postgres',
|
||||
name: 'pgdb',
|
||||
host: process.env.DB_HOST,
|
||||
@@ -75,15 +107,24 @@ const postgresProdConfig: DataSourceOptions = {
|
||||
};
|
||||
|
||||
export const isPgsql = process.env.DB_TYPE === 'postgres';
|
||||
export const pgsqlUseSSL = process.env.DB_USE_SSL === 'true';
|
||||
|
||||
function getDataSource(): DataSourceOptions {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
if (isPgsql) {
|
||||
return postgresProdConfig;
|
||||
if (pgsqlUseSSL) {
|
||||
return postgresProdConfigSSL;
|
||||
} else {
|
||||
return postgresProdConfig;
|
||||
}
|
||||
}
|
||||
return prodConfig;
|
||||
} else if (isPgsql) {
|
||||
return postgresDevConfig;
|
||||
if (pgsqlUseSSL) {
|
||||
return postgresDevConfigSSL;
|
||||
} else {
|
||||
return postgresDevConfig;
|
||||
}
|
||||
}
|
||||
return devConfig;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user