Skip to content

Commit

Permalink
Merge pull request #78 from fac-14/heroku
Browse files Browse the repository at this point in the history
Heroku
  • Loading branch information
Simon Duprée authored Sep 20, 2018
2 parents 17ea2dd + bb58dd6 commit 4d432d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
28 changes: 9 additions & 19 deletions db/db_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,16 @@ if (!DB_URL) throw new Error("Environment vatialbe must be set");
const params = url.parse(DB_URL);
const [username, password] = params.auth.split(":");

const testDB = {
host: "localhost",
port: "5432",
database: "test_race2",
user: "simon",
password: "pw123"
const options = {
host: params.hostname,
port: params.port,
database: params.pathname.split('/')[1],
max: process.env.DB_MAX_CONNECTIONS || 2,
user: username,
password,
ssl: params.hostname !== 'localhost'
};

const localDB = {
host: "localhost",
port: 5432,
database: "race_zero",
user: "simon",
password: "pw123"
};


const connection =
process.env.NODE_ENV === "test" ? testDB : localDB;

const db = pgp(connection);
const db = pgp(options);

module.exports = db;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "race-to-zero",
"version": "1.0.0",
"description": "Mobile web app to help people reduce waste in a fun motivational way",
"main": "index.js",
"main": "src/index.js",
"directories": {
"test": "test"
},
Expand Down Expand Up @@ -60,4 +60,4 @@
"pg-promise": "^8.4.6",
"serve-favicon": "^2.5.0"
}
}
}
4 changes: 2 additions & 2 deletions public/js/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ function render(challengesCompleted, pointsLeft, userPoints, myLevel) {
});
}
// 2 api request to get use specific stats and general user object
var apiRequest1 = fetch("http://localhost:3000/send-stats/").then(function (
var apiRequest1 = fetch("/send-stats/").then(function (
response
) {
return response.json();
});

var apiRequest2 = fetch("http://localhost:3000/rank/").then(function (
var apiRequest2 = fetch("/rank/").then(function (
response
) {
return response.json();
Expand Down

0 comments on commit 4d432d8

Please sign in to comment.