Skip to content

Commit

Permalink
fix: move postgres connection env var to envConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Jan 9, 2024
1 parent 7efa88d commit b66178c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 8 additions & 0 deletions envConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ const getPrefixedEnvVar = (varName, defaultValue = undefined) => {
return explicitValue ?? defaultValue;
};

// Database ============================================================================================================

// - Postgres connection URI
const PG_CONNECTION = getPrefixedEnvVar(
"PG_CONNECTION", "postgresql://postgres@localhost:5432/postgres");

// Paths and data locations ============================================================================================

// - This is the application data directory
Expand Down Expand Up @@ -80,6 +86,8 @@ const PLOT_MANHATTAN_BIN_SIZE = parseInt(getPrefixedEnvVar("MANHATTAN_BIN_SIZE",
// Export ==============================================================================================================

module.exports = {
// Database
PG_CONNECTION,
// Paths and data locations
DATA_DIR,
ABOUT_MD_PATH,
Expand Down
7 changes: 4 additions & 3 deletions models/db.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import fs from "fs";

import fs from "node:fs";
import pg from "pg";

import envConfig from "../envConfig.js";

const pool = new pg.Pool({
connectionString: process.env.VARWIG_PG_CONNECTION ?? undefined,
connectionString: envConfig.PG_CONNECTION ?? undefined,
});

export const ready = new Promise((resolve, reject) => {
Expand Down

0 comments on commit b66178c

Please sign in to comment.