New folder for middleware created. File structure reorganized

This commit is contained in:
Lucas Patenaude
2024-04-13 18:22:04 -06:00
parent 2422ecb6c3
commit 0af5ee83a6
6 changed files with 7 additions and 7 deletions

View File

@@ -1,7 +0,0 @@
function redirectToLeaguePage(leagueID) {
// Append the league name to the URL
var url = "/league/" + leagueID;
// Redirect to the league page
window.location.href = url;
}

View File

@@ -1,33 +0,0 @@
// Convert finished matches to "FT"
const convert_time = (req, res, next) => {
try {
// Access matches data from res.locals
const matches = res.locals.matches;
// Loop through matches and convert "FINISHED" to "FT" for minute
const convertedMatches = matches.map(match => {
if (match.minute === "FINISHED") {
match.minute = "FT";
}
else if (match.minute === "IN_PLAY") {
match.minute = "IP"
}
else if (match.minute === "TIMED") {
match.minute = "TM";
}
return match;
});
// Update res.locals with converted matches
res.locals.matches = convertedMatches;
// Proceed to the next middleware/route handler
next();
} catch (error) {
// If an error occurs, log it and proceed to the next middleware/route handler
console.error('Error converting finished matches:', error);
next();
}
};
module.exports = convert_time;