TASK22224: complete documents + endpoint hygiene slices
This commit is contained in:
@@ -116,6 +116,8 @@ const WEBAPI_URL =
|
||||
process.env.RELAY_ROOT ||
|
||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
||||
|
||||
const FILE_NOT_AVAILABLE_PATH = "/filenotavailable";
|
||||
|
||||
// Retry utility with logging
|
||||
async function retry(fn, retries = 3, delay = 1000) {
|
||||
for (let attempt = 1; attempt <= retries; attempt++) {
|
||||
@@ -133,6 +135,18 @@ async function retry(fn, retries = 3, delay = 1000) {
|
||||
const ApiProxy = async (req, res) => {
|
||||
const docRef = req.query;
|
||||
|
||||
if (
|
||||
typeof docRef?.id !== "string" ||
|
||||
docRef.id.length === 0 ||
|
||||
typeof docRef?.hash !== "string" ||
|
||||
docRef.hash.length === 0
|
||||
) {
|
||||
if (!res.headersSent) {
|
||||
res.redirect(FILE_NOT_AVAILABLE_PATH);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const token = await getToken();
|
||||
const startTime = Date.now();
|
||||
@@ -186,11 +200,11 @@ const ApiProxy = async (req, res) => {
|
||||
|
||||
response.data.on("error", (err) => {
|
||||
consoleLogger(err);
|
||||
if (!res.headersSent) res.redirect("/filenotavailable");
|
||||
if (!res.headersSent) res.redirect(FILE_NOT_AVAILABLE_PATH);
|
||||
});
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
if (!res.headersSent) res.redirect("/filenotavailable");
|
||||
if (!res.headersSent) res.redirect(FILE_NOT_AVAILABLE_PATH);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user