import mysql from "mysql2/promise";
import dotenv from "dotenv";

dotenv.config();

const hostingDefaults = {
  host: "localhost",
  user: "autoge9_laundry",
  password: "3259Abel%$",
  database: "autoge9_laundry",
  port: 3306
};

export const pool = mysql.createPool({
  host: process.env.DB_HOST || hostingDefaults.host,
  user: process.env.DB_USER || hostingDefaults.user,
  password: process.env.DB_PASSWORD || hostingDefaults.password,
  database: process.env.DB_NAME || hostingDefaults.database,
  port: Number(process.env.DB_PORT || hostingDefaults.port),
  waitForConnections: true,
  connectionLimit: 10,
  queueLimit: 0,
  namedPlaceholders: true,
  charset: "utf8mb4"
});
