first commit

This commit is contained in:
gzy
2025-12-16 11:39:15 +08:00
commit a3bdbee7c2
118 changed files with 34631 additions and 0 deletions

25
config/db.js Normal file
View File

@@ -0,0 +1,25 @@
const mysql = require('mysql2/promise');
require('dotenv').config();
const pool = mysql.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASS,
database: process.env.DB_DATABASE,
port: process.env.DB_PORT,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0
});
async function testConnection() {
try {
const connection = await pool.getConnection();
console.log('Successfully connected to the database !');
connection.release();
} catch (error) {
console.error('Failed to connect to the database:', error.message);
}
}
module.exports = { pool, testConnection };