-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Nothing major so feel free to ignore, but I prefer ternary assignment with const to if statements with let:
const DB_URL =
process.env.NODE_ENV === 'test'
? process.env.DATABASE_URL
: process.env.DB_URLTEST;vs
let DB_URL = process.env.DATABASE_URL;
if (process.env.NODE_ENV === 'test') {
DB_URL = process.env.DB_URLTEST;
}I also prefer the simplicity of connectionString over manual configuration for dbConnection.js:
const { Pool } = require('pg');
const environment = require('env2')('.env');
const DB_URL =
process.env.NODE_ENV === 'test'
? process.env.DATABASE_URL
: process.env.DB_URLTEST;
if (!DB_URL) {
throw new Error('Environment variable DATABASE_URL must be set');
}
const pool = new Pool({
connectionString: DB_URL,
});
module.exports = pool;Then in the config.env extra options like max and ssl can be supplied through query parameters at the end of the url:
postgres://user:password@localhost:5432/databasee?ssl=1&max=18
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels