All checks were successful
Deploy to production / deploy (push) Successful in 4m25s
- Updated the permission settings for the environment file to 640, ensuring it is readable only by the owner and the deploy group. - Modified the sequelize configuration to safely handle missing environment variables, converting them to strings or setting them to undefined to prevent runtime errors. [force-deploy]
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
const path = require('path');
|
|
const dotenv = require('dotenv');
|
|
|
|
const envPath = process.env.SEQUELIZE_ENV_FILE
|
|
? path.resolve(process.cwd(), process.env.SEQUELIZE_ENV_FILE)
|
|
: path.resolve(process.cwd(), '.env');
|
|
|
|
dotenv.config({ path: envPath });
|
|
|
|
const dialectOptions = {};
|
|
if (process.env.DB_SSL === '1' || process.env.PGSSLMODE === 'require') {
|
|
dialectOptions.ssl = process.env.DB_SSL_REJECT_UNAUTHORIZED === '0'
|
|
? { rejectUnauthorized: false }
|
|
: true;
|
|
}
|
|
|
|
// pg/SCRAM: password muss ein String sein; bei fehlender .env sonst undefined-Fallen vermeiden
|
|
const shared = {
|
|
username: process.env.DB_USER != null ? String(process.env.DB_USER) : undefined,
|
|
password: process.env.DB_PASS != null ? String(process.env.DB_PASS) : '',
|
|
database: process.env.DB_NAME != null ? String(process.env.DB_NAME) : undefined,
|
|
host: process.env.DB_HOST || '127.0.0.1',
|
|
port: Number.parseInt(process.env.DB_PORT || '5432', 10),
|
|
dialect: 'postgres',
|
|
logging: false,
|
|
dialectOptions
|
|
};
|
|
|
|
module.exports = {
|
|
development: shared,
|
|
test: shared,
|
|
production: shared
|
|
};
|