firt commit

This commit is contained in:
Kaby_Kun 2025-06-04 15:13:40 +02:00
commit c2e63830e1
71 changed files with 9613 additions and 0 deletions

29
server/utils/database.js Executable file
View file

@ -0,0 +1,29 @@
import mariadb from 'mariadb';
import dotenv from 'dotenv';
dotenv.config();
// Create a pool without database selection first
const initialPool = mariadb.createPool({
host: '172.10.1.4', // Remote database host
user: 'handball', // Remote database user
password: 'Gabi2104@', // Remote database password
database: 'handball', // Database name
connectionLimit: 5
});
export const pool = initialPool;
export async function query(sql, params) {
let conn;
try {
conn = await pool.getConnection();
const result = await conn.query(sql, params);
return result;
} catch (error) {
console.error('Database query error:', error);
throw error;
} finally {
if (conn) conn.release();
}
}