30 lines
751 B
JavaScript
30 lines
751 B
JavaScript
|
|
import mysql from 'mysql2/promise';
|
||
|
|
import dotenv from 'dotenv';
|
||
|
|
|
||
|
|
dotenv.config();
|
||
|
|
|
||
|
|
const pool = mysql.createPool({
|
||
|
|
host: process.env.DB_HOST || 'mysql',
|
||
|
|
port: process.env.DB_PORT || 3306,
|
||
|
|
user: process.env.DB_USER || 'pfandsystem',
|
||
|
|
password: process.env.DB_PASSWORD || 'pfandsystem_secure_password',
|
||
|
|
database: process.env.DB_NAME || 'pfandsystem',
|
||
|
|
waitForConnections: true,
|
||
|
|
connectionLimit: 10,
|
||
|
|
queueLimit: 0,
|
||
|
|
enableKeepAlive: true,
|
||
|
|
keepAliveInitialDelay: 0
|
||
|
|
});
|
||
|
|
|
||
|
|
// Test connection
|
||
|
|
pool.getConnection()
|
||
|
|
.then(connection => {
|
||
|
|
console.log('✅ MySQL Datenbankverbindung erfolgreich');
|
||
|
|
connection.release();
|
||
|
|
})
|
||
|
|
.catch(err => {
|
||
|
|
console.error('❌ MySQL Verbindungsfehler:', err.message);
|
||
|
|
});
|
||
|
|
|
||
|
|
export default pool;
|