I found some other similar answers to this, but I was not confident in my ability to comprehend and get it right, so I'm hoping to get a little validation on my approach if it's right, seeing as what i've cobbled together is from a tutorial. I've also included the requires, as I'm not actually calling express in this file (db.js) but it is used in other places:
(PS. I am deploying to Heroku, and using JawsDB as my production DB)
require("dotenv").config();
const mysql = require("mysql2");
//const { DatabaseError } = require('pg');
const pool = mysql.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
database: process.env.DB_NAME,
password: process.env.DB_PASSWORD,
});
and this is what i'm thinking of doing:
app.configure('production', function(){
app.locals.URLs = {
const pool = mysql.createPool({
host: process.env.DB_HOST_LOCAL,
user: process.env.DB_USER_LOCAL,
database: process.env.DB_NAME_LOCAL,
password: process.env.DB_PASSWORD_LOCAL,
}
});
app.configure('development', function(){
app.locals.URLs = {
const pool = mysql.createPool({
host: process.env.DB_HOST_JAWS,
user: process.env.DB_USER_JAWS,
database: process.env.DB_NAME_JAWS,
password: process.env.DB_PASSWORD_JAWS,
}
});
is this right, and will I need to require app = require('express')
?