import { Pool } from "pg";
import { cfg } from "../config";

export const pool = new Pool({
  host: cfg.db.host,
  port: cfg.db.port,
  database: cfg.db.database,
  user: cfg.db.user,
  password: cfg.db.password,
  max: 20,
  idleTimeoutMillis: 30000,
  connectionTimeoutMillis: 5000,
});

pool.on("error", (err) => {
  console.error("Unexpected PostgreSQL error:", err);
});
