TASK22224: complete documents + endpoint hygiene slices

This commit is contained in:
2026-03-24 06:12:04 +00:00
parent dfdfd3653c
commit fe394f3fa8
6 changed files with 221 additions and 189 deletions
+16 -2
View File
@@ -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);
}
};