TASK22224: big parity bundle for completion message routes

This commit is contained in:
2026-03-23 18:09:36 +00:00
parent 9f5ec6f50a
commit 91a0ab82ea
4 changed files with 200 additions and 109 deletions
+36 -22
View File
@@ -13,10 +13,10 @@ const ApiProxy = nextConnect();
ApiProxy.use(middleware);
ApiProxy.get(async (req, res) => {
var containerName = req.query.container;
var tempCaseRef = req.query.tempcaseref;
var filename = req.query.repid;
var checkHash = req.query.hash;
const containerName = req.query.container;
const tempCaseRef = req.query.tempcaseref;
const filename = req.query.repid;
const checkHash = req.query.hash;
if (
typeof containerName === "undefined" ||
@@ -35,15 +35,26 @@ ApiProxy.get(async (req, res) => {
});
}
var checkquerypath =
const hashCandidatePaths = [
"/api/file/createrepcompletemessage_api?container=" +
containerName +
"&tempcaseref=" +
tempCaseRef +
"&repid=" +
filename;
containerName +
"&tempcaseref=" +
tempCaseRef +
"&repid=" +
filename,
"/api/file/createrepcompletemessage_api?container=" +
encodeURIComponent(containerName) +
"&tempcaseref=" +
encodeURIComponent(tempCaseRef) +
"&repid=" +
encodeURIComponent(filename)
];
if (hashAPIPath(checkquerypath) != "&hash=" + checkHash) {
const isHashValid = hashCandidatePaths.some(
(candidatePath) => hashAPIPath(candidatePath) == "&hash=" + checkHash
);
if (!isHashValid) {
return respondError(res, {
status: 400,
code: "INVALID_HASH",
@@ -51,18 +62,21 @@ ApiProxy.get(async (req, res) => {
});
}
await createRepCompleteMessage(containerName, tempCaseRef, filename)
.then((data) => {
return respondSuccess(res, data);
})
.catch((error) => {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "CREATE_REP_COMPLETE_MESSAGE_FAILED",
message: "Failed to create representation complete message"
});
try {
const data = await createRepCompleteMessage(
containerName,
tempCaseRef,
filename
);
return respondSuccess(res, data);
} catch (error) {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "CREATE_REP_COMPLETE_MESSAGE_FAILED",
message: "Failed to create representation complete message"
});
}
});
export const config = {