refactor(api): migrate batch 9 endpoints to relayGet

This commit is contained in:
2026-03-24 09:59:59 +00:00
parent 13be069b8b
commit e8d4e8563e
6 changed files with 125 additions and 173 deletions
@@ -1,13 +1,6 @@
import axios from "axios";
import { azureHeadersNoOdata } from "../../../actions/core/headers";
import { consoleLogger } from "../../../actions/core/logger";
import { getToken } from "../../../actions/core/token";
import { hashAPIPath } from "../../../actions/core/hash";
import { respondError, respondSuccess } from "../middleware/apiResponse";
const WEBAPI_URL =
process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
export default async function ApiProxy(req, res) {
const appealTypeName = req.query.appealTypeName;
@@ -44,29 +37,23 @@ export default async function ApiProxy(req, res) {
});
}
try {
const token = await getToken();
const queryUrl =
appealTypeName +
"?$filter=_" +
primaryIdAttribute +
"s_value eq " +
incidentID +
"&$count=true";
const queryUrl =
appealTypeName +
"?$filter=_" +
primaryIdAttribute +
"s_value eq " +
incidentID +
"&$count=true";
const { data } = await axios.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersNoOdata(token.access_token)
);
return respondSuccess(res, data);
} catch (error) {
consoleLogger(error);
return respondError(res, {
return relayGet({
queryUrl,
res,
requestOptionsBuilder: (accessToken) =>
azureHeadersNoOdata(accessToken),
errorResponse: {
status: 400,
code: "BASIC_PART_SAVED_DETAILS_FETCH_FAILED",
message: "Failed to fetch basic part-saved details"
});
}
}
});
}