import { env } from '$env/dynamic/private';
import mysql from 'mysql2/promise';

const pool = mysql.createPool({
	host: env.MYSQL_HOST ?? 'localhost',
	port: Number(env.MYSQL_PORT ?? 3306),
	user: env.MYSQL_USER ?? 'root',
	password: env.MYSQL_PASSWORD ?? '',
	database: env.MYSQL_DATABASE ?? 'catatanwarung',
	waitForConnections: true,
	connectionLimit: 10,
	queueLimit: 0,
	enableKeepAlive: true,
	keepAliveInitialDelay: 0
});

export default pool;
