You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
578 B
TypeScript
37 lines
578 B
TypeScript
import dotenv from "dotenv";
|
|
import { Pool } from "pg";
|
|
|
|
dotenv.config();
|
|
|
|
const {
|
|
ENV,
|
|
POSTGRES_HOST,
|
|
POSTGRES_DB,
|
|
POSTGRES_TEST_DB,
|
|
POSTGRES_USER,
|
|
POSTGRES_PASSWORD,
|
|
} = process.env;
|
|
|
|
let client = new Pool();
|
|
|
|
if (ENV === "dev") {
|
|
client = new Pool({
|
|
host: POSTGRES_HOST,
|
|
database: POSTGRES_DB,
|
|
user: POSTGRES_USER,
|
|
password: POSTGRES_PASSWORD,
|
|
});
|
|
}
|
|
|
|
if (ENV === "test") {
|
|
client = new Pool({
|
|
host: POSTGRES_HOST,
|
|
database: POSTGRES_TEST_DB,
|
|
user: POSTGRES_USER,
|
|
password: POSTGRES_PASSWORD,
|
|
});
|
|
}
|
|
|
|
export default client;
|
|
|