TASK22224: harden proxy file routes and expand contracts

This commit is contained in:
2026-03-23 18:14:22 +00:00
parent 91a0ab82ea
commit 3f2b945172
6 changed files with 258 additions and 70 deletions
@@ -17,8 +17,8 @@ const hasValue = (value) =>
typeof value === "string" && value.trim().length > 0;
ApiProxy.get(async (req, res) => {
var containerName = req.query.container;
var tempCaseRef = req.query.tempcaseref;
const containerName = req.query.container;
const tempCaseRef = req.query.tempcaseref;
if (!hasValue(containerName) || !hasValue(tempCaseRef)) {
return respondError(res, {
@@ -28,30 +28,28 @@ ApiProxy.get(async (req, res) => {
});
}
var token = await getToken();
const token = await getToken();
var queryUrl =
const queryUrl =
"/api/file/createappealcompletemessage_api?container=" +
containerName +
encodeURIComponent(containerName) +
"&tempcaseref=" +
tempCaseRef;
encodeURIComponent(tempCaseRef);
return axios
.get(
try {
const { data } = await axios.get(
BASE_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
return respondSuccess(res, data);
})
.catch((error) => {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "CREATE_APPEAL_COMPLETE_MESSAGE_PROXY_FAILED",
message: "Failed to create appeal complete message"
});
);
return respondSuccess(res, data);
} catch (error) {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "CREATE_APPEAL_COMPLETE_MESSAGE_PROXY_FAILED",
message: "Failed to create appeal complete message"
});
}
});
export const config = {
@@ -11,7 +11,7 @@ const hasValue = (value) =>
typeof value === "string" && value.trim().length > 0;
export default async function ApiProxy(req, res) {
var containerName = req.query.container;
const containerName = req.query.container;
if (!hasValue(containerName)) {
return respondError(res, {
@@ -21,25 +21,23 @@ export default async function ApiProxy(req, res) {
});
}
var token = await getToken();
const token = await getToken();
var queryUrl =
const queryUrl =
"/api/file/getawaitingsubmissionfromblob?container=" + containerName;
return axios
.get(
try {
const { data } = await axios.get(
BASE_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
return respondSuccess(res, data);
})
.catch((error) => {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "GET_AWAITING_SUBMISSION_PROXY_FAILED",
message: "Failed to fetch awaiting submission blob"
});
);
return respondSuccess(res, data);
} catch (error) {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "GET_AWAITING_SUBMISSION_PROXY_FAILED",
message: "Failed to fetch awaiting submission blob"
});
}
}
+17 -19
View File
@@ -11,8 +11,8 @@ const hasValue = (value) =>
typeof value === "string" && value.trim().length > 0;
export default async function ApiProxy(req, res) {
var containerName = req.query.container;
var casefolderID = req.query.casefolderID;
const containerName = req.query.container;
const casefolderID = req.query.casefolderID;
if (!hasValue(containerName) || !hasValue(casefolderID)) {
return respondError(res, {
@@ -22,28 +22,26 @@ export default async function ApiProxy(req, res) {
});
}
var token = await getToken();
const token = await getToken();
var queryUrl =
const queryUrl =
"/api/file/getbloblist?container=" +
containerName +
encodeURIComponent(containerName) +
"&casefolderID=" +
casefolderID;
encodeURIComponent(casefolderID);
return axios
.get(
try {
const { data } = await axios.get(
BASE_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
return respondSuccess(res, data);
})
.catch((error) => {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "GET_BLOB_LIST_PROXY_FAILED",
message: "Failed to fetch blob list"
});
);
return respondSuccess(res, data);
} catch (error) {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "GET_BLOB_LIST_PROXY_FAILED",
message: "Failed to fetch blob list"
});
}
}
+15 -16
View File
@@ -11,7 +11,7 @@ const hasValue = (value) =>
typeof value === "string" && value.trim().length > 0;
export default async function ApiProxy(req, res) {
var containerName = req.query.container;
const containerName = req.query.container;
if (!hasValue(containerName)) {
return respondError(res, {
@@ -21,24 +21,23 @@ export default async function ApiProxy(req, res) {
});
}
var token = await getToken();
const token = await getToken();
var queryUrl = "/api/file/getrepsblob?container=" + containerName;
const queryUrl =
"/api/file/getrepsblob?container=" + encodeURIComponent(containerName);
return axios
.get(
try {
const { data } = await axios.get(
BASE_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
return respondSuccess(res, data);
})
.catch((error) => {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "GET_REPS_BLOB_PROXY_FAILED",
message: "Failed to fetch representation blobs"
});
);
return respondSuccess(res, data);
} catch (error) {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "GET_REPS_BLOB_PROXY_FAILED",
message: "Failed to fetch representation blobs"
});
}
}