diff --git a/containers/tefca-viewer/src/app/database-service.ts b/containers/tefca-viewer/src/app/database-service.ts index af6832976..bd7592355 100644 --- a/containers/tefca-viewer/src/app/database-service.ts +++ b/containers/tefca-viewer/src/app/database-service.ts @@ -1,6 +1,6 @@ "use server"; import { Pool, PoolConfig, QueryResultRow } from "pg"; -// import dotenv from "dotenv"; +import dotenv from "dotenv"; import { ValueSetItem, valueSetTypeToClincalServiceTypeMap } from "./constants"; const getQuerybyNameSQL = ` @@ -13,7 +13,10 @@ select q.query_name, q.id, qtv.valueset_id, vs.name as valueset_name, vs.author where q.query_name = $1; `; -// Load environment variables from .env and establish a Pool configuration +// Load environment variables from tefca.env if not in production +if (process.env.NODE_ENV !== "production") { + dotenv.config({ path: "tefca.env" }); +} const dbConfig: PoolConfig = { connectionString: process.env.DATABASE_URL, max: 10, // Maximum # of connections in the pool diff --git a/containers/tefca-viewer/tefca.env b/containers/tefca-viewer/tefca.env new file mode 100644 index 000000000..4554f1170 --- /dev/null +++ b/containers/tefca-viewer/tefca.env @@ -0,0 +1 @@ +DATABASE_URL=postgresql://postgres:pw@localhost:5432/tefca_db \ No newline at end of file