Files
portaldata/lib/db.ts
Randa Firman Putra e028039ee2 First commit
2025-06-18 22:03:32 +07:00

28 lines
651 B
TypeScript

import mysql from 'mysql2/promise';
const pool = mysql.createPool({
host: '127.0.0.1',
port: 3306,
user: 'root',
password: 'semogabisayok321',
database: 'mhsdb',
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0
});
// Test the connection
const testConnection = async () => {
try {
const connection = await pool.getConnection();
console.log('Database connection successful');
connection.release();
return true;
} catch (error) {
console.error('Database connection failed:', error);
return false;
}
};
// Export both the pool and the test function
export { pool as default, testConnection };