21 lines
519 B
JavaScript
21 lines
519 B
JavaScript
import pg from "pg";
|
|
import "dotenv/config";
|
|
|
|
const { Pool } = pg;
|
|
|
|
const baseConfig = {};
|
|
|
|
baseConfig.host = process.env.PGHOST || "127.0.0.1";
|
|
baseConfig.port = Number(process.env.PGPORT || 5432);
|
|
baseConfig.user = process.env.PGUSER || "postgres";
|
|
baseConfig.password = process.env.PGPASSWORD || "postgres";
|
|
baseConfig.database = process.env.PGDATABASE || "postgres";
|
|
|
|
const pool = new Pool(baseConfig);
|
|
|
|
pool.on("error", (err) => {
|
|
console.error("Unexpected Postgres client error", err);
|
|
});
|
|
|
|
export default pool;
|