Compare commits
4 Commits
d49a5ae034
...
9d51d4e45e
Author | SHA1 | Date |
---|---|---|
Fred Boniface | 9d51d4e45e | |
Fred Boniface | fde37814a7 | |
Fred Boniface | 8fa0cf775f | |
Fred Boniface | afa4ad7915 |
|
@ -5,7 +5,7 @@ interface versions {
|
|||
|
||||
const version: versions = {
|
||||
api: ["/api/v2"],
|
||||
app: "2024.04.3",
|
||||
app: "2024.04.4",
|
||||
};
|
||||
|
||||
module.exports = version;
|
||||
|
|
|
@ -9,7 +9,7 @@ async function getTrain(req, res, next) {
|
|||
err.status = 401;
|
||||
throw err;
|
||||
}
|
||||
setCache(res, "private", 180)
|
||||
setCache(res, "private", 240)
|
||||
let type = req.params.searchType;
|
||||
let id = req.params.id;
|
||||
try {
|
||||
|
@ -45,8 +45,14 @@ async function getStation(req, res, next) {
|
|||
err.status = 401;
|
||||
return next(err);
|
||||
}
|
||||
setCache(res, "public", 120)
|
||||
res.json(await ldb.get(id, true));
|
||||
const data = await ldb.get(id, true);
|
||||
// Only cache if data is present
|
||||
if (data.data) {
|
||||
setCache(res, "public", 120);
|
||||
} else {
|
||||
setCache(res, "no-store", 120);
|
||||
}
|
||||
res.json(data);
|
||||
} else {
|
||||
setCache(res, "public", 240)
|
||||
res.json(await ldb.get(id, false));
|
||||
|
|
|
@ -18,6 +18,7 @@ async function getReasonCode(req, res, next) {
|
|||
} catch (err) {
|
||||
console.error("ERROR", err.message);
|
||||
err.status = 500;
|
||||
setCache(res, "no-store", 5)
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,21 +21,19 @@ module.exports = async function authCheck(
|
|||
} else if (typeof id === "string") {
|
||||
const authCheck = (await isAuthed(id)) || false;
|
||||
if (authCheck) {
|
||||
// Authenticate
|
||||
req.isAuthed = true;
|
||||
logger.info("auth.middleware: Authentication Successful");
|
||||
next();
|
||||
} else {
|
||||
req.isAuthed = false;
|
||||
logger.info("auth.middleware: Authentication Failed");
|
||||
next();
|
||||
}
|
||||
// Handle cases where UUID passed as an array
|
||||
} else if (Array.isArray(id)) {
|
||||
const authCheck = (await isAuthed(id[0])) || false;
|
||||
if (authCheck) {
|
||||
req.isAuthed = true;
|
||||
logger.warn(
|
||||
"auth.middleware: UUID Passed as Array - Authentication Successful"
|
||||
);
|
||||
next();
|
||||
} else {
|
||||
req.isAuthed = false;
|
||||
|
|
|
@ -141,6 +141,7 @@ async function staffApiCallRetry(api, method, options, retries) {
|
|||
logger.warn(err, "DNS ERR")
|
||||
if (i < retries - 1) {
|
||||
logger.debug('Retrying API Call')
|
||||
await delay(500)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -150,6 +151,10 @@ async function staffApiCallRetry(api, method, options, retries) {
|
|||
throw new Error("Max retries exceeded");
|
||||
}
|
||||
|
||||
function delay(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
async function getReasonCodeList() {
|
||||
logger.debug("ldbService.getReasonCodeList: Fetching reason code list");
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue