Actually get DB endpoint from env vars
Some checks failed
/ prettier (pull_request) Successful in 28s
/ node-check (pull_request) Successful in 3s
/ boot (pull_request) Successful in 15s
/ tests (pull_request) Has been cancelled

This commit is contained in:
9pfs 2024-06-14 07:32:50 +00:00
parent 6330c02389
commit 491d8918df
Signed by: 9pfs
SSH key fingerprint: SHA256:TOcGxMQCfy4VvRM8AzgXErKXdkAtaTcpGXgYMpyoJoY

23
db.js
View file

@ -1,12 +1,15 @@
import postgres from "postgres";
const sql = postgres(
process.env.DB_CONNECTION_STRING || process.env.NODE_ENV == "production"
? "postgres://h_countify-prod?host=%2Fvar%2Flib%2Fpostgresql"
: {
host: "/var/run/postgresql",
database: "h_countify-dev",
debug: true,
},
);
var db_endpoint;
db_endpoint = process.env?.DB_CONNECTION_STRING;
if (!db_endpoint) {
db_endpoint =
process.env.NODE_ENV == "production"
? "postgres://h_countify-prod?host=%2Fvar%2Flib%2Fpostgresql"
: {
host: "/var/run/postgresql",
database: "h_countify-dev",
debug: true,
};
}
const sql = postgres(db_endpoint);
export default sql;