First commit

This commit is contained in:
Randa Firman Putra
2025-06-18 22:03:32 +07:00
parent 852121be46
commit e028039ee2
123 changed files with 17506 additions and 144 deletions

28
lib/db.ts Normal file
View File

@@ -0,0 +1,28 @@
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 };