import mysql from 'mysql2/promise';

export const db = mysql.createPool({
  host: process.env.DB_HOST,
  user: process.env.DB_USER,
  password: process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
  port: Number(process.env.DB_PORT) || 4000,
  // Opsi SSL di bawah ini WAJIB ada agar bisa nyambung ke TiDB
  ssl: {
    rejectUnauthorized: true
  }
});