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.
36 lines
585 B
TypeScript
36 lines
585 B
TypeScript
import dotenv from 'dotenv'
|
|
import { Pool } from 'pg'
|
|
|
|
dotenv.config()
|
|
|
|
const {
|
|
POSTGRES_HOST,
|
|
POSTGRES_DB,
|
|
POSTGRES_USER,
|
|
POSTGRES_PASSWORD,
|
|
POSTGRES_TEST_DB,
|
|
ENV,
|
|
} = process.env
|
|
|
|
let client = new Pool();
|
|
console.log(ENV)
|
|
|
|
if(ENV === 'test') {
|
|
client = new Pool({
|
|
host: POSTGRES_HOST,
|
|
database: POSTGRES_TEST_DB,
|
|
user: POSTGRES_USER,
|
|
password: POSTGRES_PASSWORD,
|
|
})
|
|
}
|
|
|
|
if(ENV === 'dev') {
|
|
client = new Pool({
|
|
host: POSTGRES_HOST,
|
|
database: POSTGRES_DB,
|
|
user: POSTGRES_USER,
|
|
password: POSTGRES_PASSWORD,
|
|
})
|
|
}
|
|
|
|
export default client; |