chore: Add env variable to toggle postgresql ssl flag

This commit is contained in:
Faruk AYDIN
2021-11-23 14:32:52 +01:00
committed by Ali BARIN
parent cf1fa9039b
commit a5811d44ac
3 changed files with 6 additions and 3 deletions

View File

@@ -7,4 +7,5 @@ POSTGRES_DATABASE=automatisch_development
POSTGRES_PORT=5432 POSTGRES_PORT=5432
POSTGRES_HOST=localhost POSTGRES_HOST=localhost
POSTGRES_USERNAME=automatish_development_user POSTGRES_USERNAME=automatish_development_user
POSTGRESS_PASSWORD= POSTGRES_PASSWORD=
POSTGRES_ENABLE_SSL=false

View File

@@ -8,7 +8,7 @@ const knexConfig = {
user: appConfig.postgresUsername, user: appConfig.postgresUsername,
password: appConfig.postgresPassword, password: appConfig.postgresPassword,
database: appConfig.postgresDatabase, database: appConfig.postgresDatabase,
ssl: true, ssl: appConfig.postgresEnableSsl
}, },
migrations: { migrations: {
directory: __dirname + '/src/db/migrations', directory: __dirname + '/src/db/migrations',

View File

@@ -12,6 +12,7 @@ type AppConfig = {
postgresHost: string, postgresHost: string,
postgresUsername: string, postgresUsername: string,
postgresPassword: string, postgresPassword: string,
postgresEnableSsl: boolean,
baseUrl?: string baseUrl?: string
} }
@@ -25,7 +26,8 @@ const appConfig: AppConfig = {
postgresPort: parseInt(process.env.POSTGRES_PORT) || 5432, postgresPort: parseInt(process.env.POSTGRES_PORT) || 5432,
postgresHost: process.env.POSTGRES_HOST || 'localhost', postgresHost: process.env.POSTGRES_HOST || 'localhost',
postgresUsername: process.env.POSTGRES_USERNAME || 'automatish_development_user', postgresUsername: process.env.POSTGRES_USERNAME || 'automatish_development_user',
postgresPassword: process.env.POSTGRESS_PASSWORD, postgresPassword: process.env.POSTGRES_PASSWORD,
postgresEnableSsl: process.env.POSTGRES_ENABLE_SSL === 'true' ? true : false,
} }
const baseUrl = `${appConfig.protocol}://${appConfig.host}:${appConfig.port}`; const baseUrl = `${appConfig.protocol}://${appConfig.host}:${appConfig.port}`;