Last active
February 7, 2018 06:08
-
-
Save ma-he-sh/57d9b9308e01a87722039ed3a56b3539 to your computer and use it in GitHub Desktop.
Heroku PostgreSQL SSL Connection, NodeJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**Heroku connection credentials */ | |
var dbconnect = { | |
dbhost: "", | |
db: "", | |
dbuser: "", | |
dbport: "5432", | |
dbpassw: "" | |
} | |
module.exports.dbconnect = dbconnect; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var remoteDB = require("./config"); | |
const { | |
Client | |
} = require('pg') | |
/**Connection credentials */ | |
const client = new Client({ | |
user: remoteDB.dbconnect.dbuser, | |
host: remoteDB.dbconnect.dbhost, | |
database: remoteDB.dbconnect.db, | |
password: remoteDB.dbconnect.dbpassw, | |
port: remoteDB.dbconnect.dbport, | |
ssl: true //- << Ensures SSL Connection | |
}); | |
client.connect(); | |
client.on('error', (err, client) => { | |
console.error('Unexpected error on idle client', err); | |
process.exit(-1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment