Compare commits

..

No commits in common. "9d51d4e45e1b5d0ef935ed23a5a91b3e5951a993" and "d49a5ae034960d20732139941e5bcfccf3440ec2" have entirely different histories.

5 changed files with 8 additions and 18 deletions

View File

@ -5,7 +5,7 @@ interface versions {
const version: versions = { const version: versions = {
api: ["/api/v2"], api: ["/api/v2"],
app: "2024.04.4", app: "2024.04.3",
}; };
module.exports = version; module.exports = version;

View File

@ -9,7 +9,7 @@ async function getTrain(req, res, next) {
err.status = 401; err.status = 401;
throw err; throw err;
} }
setCache(res, "private", 240) setCache(res, "private", 180)
let type = req.params.searchType; let type = req.params.searchType;
let id = req.params.id; let id = req.params.id;
try { try {
@ -45,14 +45,8 @@ async function getStation(req, res, next) {
err.status = 401; err.status = 401;
return next(err); return next(err);
} }
const data = await ldb.get(id, true); setCache(res, "public", 120)
// Only cache if data is present res.json(await ldb.get(id, true));
if (data.data) {
setCache(res, "public", 120);
} else {
setCache(res, "no-store", 120);
}
res.json(data);
} else { } else {
setCache(res, "public", 240) setCache(res, "public", 240)
res.json(await ldb.get(id, false)); res.json(await ldb.get(id, false));

View File

@ -18,7 +18,6 @@ async function getReasonCode(req, res, next) {
} catch (err) { } catch (err) {
console.error("ERROR", err.message); console.error("ERROR", err.message);
err.status = 500; err.status = 500;
setCache(res, "no-store", 5)
next(err); next(err);
} }
} }

View File

@ -21,19 +21,21 @@ module.exports = async function authCheck(
} else if (typeof id === "string") { } else if (typeof id === "string") {
const authCheck = (await isAuthed(id)) || false; const authCheck = (await isAuthed(id)) || false;
if (authCheck) { if (authCheck) {
// Authenticate
req.isAuthed = true; req.isAuthed = true;
logger.info("auth.middleware: Authentication Successful");
next(); next();
} else { } else {
req.isAuthed = false; req.isAuthed = false;
logger.info("auth.middleware: Authentication Failed"); logger.info("auth.middleware: Authentication Failed");
next(); next();
} }
// Handle cases where UUID passed as an array
} else if (Array.isArray(id)) { } else if (Array.isArray(id)) {
const authCheck = (await isAuthed(id[0])) || false; const authCheck = (await isAuthed(id[0])) || false;
if (authCheck) { if (authCheck) {
req.isAuthed = true; req.isAuthed = true;
logger.warn(
"auth.middleware: UUID Passed as Array - Authentication Successful"
);
next(); next();
} else { } else {
req.isAuthed = false; req.isAuthed = false;

View File

@ -141,7 +141,6 @@ async function staffApiCallRetry(api, method, options, retries) {
logger.warn(err, "DNS ERR") logger.warn(err, "DNS ERR")
if (i < retries - 1) { if (i < retries - 1) {
logger.debug('Retrying API Call') logger.debug('Retrying API Call')
await delay(500)
continue; continue;
} }
} }
@ -151,10 +150,6 @@ async function staffApiCallRetry(api, method, options, retries) {
throw new Error("Max retries exceeded"); throw new Error("Max retries exceeded");
} }
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function getReasonCodeList() { async function getReasonCodeList() {
logger.debug("ldbService.getReasonCodeList: Fetching reason code list"); logger.debug("ldbService.getReasonCodeList: Fetching reason code list");
try { try {