Skip to content

Commit

Permalink
reverted back to singular credential specs. Refactored it into .env f…
Browse files Browse the repository at this point in the history
…ile though. PG Operator generators the connection URI based on a default database so elevation database connection would not work.
  • Loading branch information
amyfromandi committed Sep 23, 2024
1 parent 8f1d710 commit 93f4456
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MACRO_HOST: process.env.host
MACRO_USERNAME: process.env.username
MACRO_PASSWORD: process.env.password
MACRO_DATABASE: process.env.database
CACHE_REFRESH_KEY=
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ v1/npm-debug.log
v1/utilities/scripts/credentials.py
.idea
venv
.env

!v1/credentials.ts
v2/utilities/scripts/credentials.py
Expand Down
22 changes: 16 additions & 6 deletions v2/larkin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ const postgresDatabases = {
geomacro: "geomacro",
elevation: "elevation",
};

const pgConnection = {
host: process.env.MACRO_HOST,
user: process.env.MACRO_USER,
password: process.env.MACRO_PASSWORD,
database: process.env.MACRO_DATABASE
}

(function () {
var larkin = {};

Expand Down Expand Up @@ -86,16 +94,18 @@ const postgresDatabases = {
"In Macrostrat v2, 'geomacro' is merged with 'burwell' into the 'macrostrat' database.",
);
}
let connectionDetails = process.env.MACROSTRAT_DB_URL;
//TODO - PG operator only generates a single connection, so this is not suitable for multiple databases

let connectionDetails = {...pgConnection};

if (dbName == "elevation") {
/* Special case for elevation database (temporary) */
connectionDetails = process.env.ELEVATION_DB_URL;
// Special case for elevation database (temporary)
pgConnection.database
connectionDetails.database = 'elevation';
}

const pool = new Pool({
connectionString: connectionDetails
});
const pool = new Pool({connectionDetails});
console.log(connectionDetails)

pool.connect(function (err, client, done) {
if (err) {
Expand Down

0 comments on commit 93f4456

Please sign in to comment.