refactor(api): migrate batch 7 endpoints to relayGet

This commit is contained in:
2026-03-24 09:43:17 +00:00
parent 6da6fdb4d2
commit bd15fd18e1
7 changed files with 188 additions and 194 deletions
@@ -23,17 +23,9 @@
* description: hello world
*/
import axios from "axios";
import { azureHeaders } from "../../../actions/core/headers";
import { consoleLogger } from "../../../actions/core/logger";
import { getToken } from "../../../actions/core/token";
import { getSelectQuery } from "../../../actions/selectQueryTypes";
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 appealType = req.query.appealType;
@@ -58,30 +50,23 @@ export default async function ApiProxy(req, res) {
});
}
try {
const token = await getToken();
const escapedCaseReference = caseReference.split("'").join("''");
const escapedCaseReference = caseReference.split("'").join("''");
let queryUrl =
appealType +
"?$filter=pinswg_name eq '" +
escapedCaseReference +
"'&$count=true";
let queryUrl =
appealType +
"?$filter=pinswg_name eq '" +
escapedCaseReference +
"'&$count=true";
queryUrl = queryUrl + getSelectQuery(appealType);
queryUrl = queryUrl + getSelectQuery(appealType);
const { data } = await axios.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
);
return respondSuccess(res, data);
} catch (error) {
consoleLogger(error);
return respondError(res, {
return relayGet({
queryUrl,
res,
errorResponse: {
status: 400,
code: "PORTAL_MODULE_DETAILS_PROXY_FETCH_FAILED",
message: "Failed to fetch portal module details proxy"
});
}
}
});
}