1
0
mirror of https://dev.s-ul.net/Galexion/MaiMaiDXNet.git synced 2024-09-24 06:18:20 +02:00

Hotfix #2: thanks for waiting

This commit is contained in:
Galexion 2023-07-19 13:54:45 -04:00
parent 769317c0d7
commit 39fb90e14b

View File

@ -7,12 +7,27 @@ if (serverType === 0) {
const mysql = require('mysql');
//var con = mysql.createConnection(ArtConnSettings);
var pool = mysql.createPool(ArtConnSettings);
var con = undefined
if (serverType === 1) {
function establishConnection() {
return new Promise((resolve, reject) => {
pool.getConnection(function(err, con) {
if (err) throw err; // not connected!
resolve(con);
con.on('error', function(err) {
console.log('MySQL error', err);
if (err.code === 'PROTOCOL_CONNECTION_LOST') {
console.log('Reconnecting MySQL connection...');
con = mysql.createConnection(connection.config);
pool.getConnection(function(err, connection) {
if (err) throw err; // not connected!
con = connection;
});
} else {
throw err;
}
});
});
});
}
}
// index.js route '/'
@ -30,6 +45,7 @@ async function getUserCount() {
});
});
} else {
var con = await establishConnection();
return new Promise((resolve, reject) => {
con.query("SELECT * FROM aime.mai2_profile_detail", function (err, result, fields) {
if (err) {
@ -71,6 +87,7 @@ async function getUserData(req) {
});
}); // function is required to obtain the User Data, and create the user profile. I'm going to bed.
} else { // 07-23 oh god im going to have to recreate this function again aren't i
var con = await establishConnection();
return new Promise((resolve, reject) => {
con.query("SELECT * FROM aime.mai2_profile_detail", function (err, result, fields) {
if (err) {
@ -82,7 +99,6 @@ async function getUserData(req) {
const cookies = req.cookies
var mUser = undefined // Leave the Matched User undefined until the user is found.
for (user of result) { // For Each User in Rows
console.log(user.user)
if (cookies.aime_card_id === user.user.toString()) { // If the Access Code for the card is in the system,
mUser = user; // set the Matched User Variable to the User, and break the for Loop.
break;
@ -126,6 +142,7 @@ async function getExtId(req) {
});
});
} else {
var con = await establishConnection();
return new Promise((resolve, reject) => {
con.query("SELECT * FROM aime.aime_card", function (err, result, fields) {
if (err) {
@ -177,6 +194,7 @@ async function getUserScores(req) {
});
});
} else {
var con = await establishConnection();
return new Promise((resolve, reject) => {
con.query("SELECT * FROM aime.mai2_playlog", function (err, result, fields) {
if (err) {
@ -191,7 +209,6 @@ async function getUserScores(req) {
var request = req.body;
var mUser = new Array(); // Leave the Matched User's Scores undefined until the user is found.
for (score of result) { // For Each Score in Rows
console.log(request.input)
if (request.input == score.user) { // If the inputed User ID and Score's User ID Matches,
mUser.push(score) // add that score into the array.
}
@ -228,6 +245,7 @@ async function getUserArea(req) {
});
});
} else {
var con = await establishConnection();
return new Promise((resolve, reject) => {
con.query("SELECT * FROM aime.mai2_item_map", function (err, result, fields) {
if (err) {