Actually get DB endpoint from env vars
This commit is contained in:
parent
6330c02389
commit
491d8918df
1 changed files with 13 additions and 10 deletions
13
db.js
13
db.js
|
@ -1,12 +1,15 @@
|
||||||
import postgres from "postgres";
|
import postgres from "postgres";
|
||||||
|
var db_endpoint;
|
||||||
const sql = postgres(
|
db_endpoint = process.env?.DB_CONNECTION_STRING;
|
||||||
process.env.DB_CONNECTION_STRING || process.env.NODE_ENV == "production"
|
if (!db_endpoint) {
|
||||||
|
db_endpoint =
|
||||||
|
process.env.NODE_ENV == "production"
|
||||||
? "postgres://h_countify-prod?host=%2Fvar%2Flib%2Fpostgresql"
|
? "postgres://h_countify-prod?host=%2Fvar%2Flib%2Fpostgresql"
|
||||||
: {
|
: {
|
||||||
host: "/var/run/postgresql",
|
host: "/var/run/postgresql",
|
||||||
database: "h_countify-dev",
|
database: "h_countify-dev",
|
||||||
debug: true,
|
debug: true,
|
||||||
},
|
};
|
||||||
);
|
}
|
||||||
|
const sql = postgres(db_endpoint);
|
||||||
export default sql;
|
export default sql;
|
||||||
|
|
Loading…
Reference in a new issue