forked from lucaspatenaude/ScoreSpot
New folder for middleware created. File structure reorganized
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user