moved hashapipath to reusable single helper

This commit is contained in:
2026-03-16 11:13:41 +00:00
parent 023a8e9e6d
commit 18dfc60754
74 changed files with 298 additions and 1149 deletions
+6 -19
View File
@@ -4,25 +4,12 @@ import { azureHeaders } from "../../../actions/core/headers";
import { consoleLogger } from "../../../actions/core/logger";
import { getToken } from "../../../actions/core/token";
import OSPoint from "ospoint";
const WORDKEY = process.env.HASHKEY;
import { hashAPIPath } from "../../../actions/core/hash";
const WEBAPI_URL =
process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
const hashAPIPath = (queryPath) => {
var hashlink = CryptoJS.HmacSHA256(
queryPath,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString(CryptoJS.enc.Hex);
//return "&hash=" + hashlink;
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
const renameKeys = (obj) => {
const keyMappings = {
"pinswg_projectlocation": "location",
@@ -41,7 +28,7 @@ const renameKeys = (obj) => {
"appellantDisplayName",
"_pinswg_appellant_value": "appellantId",
"zoom": "mapZoom",
"center": "locationCenter",
"center": "locationCenter"
};
let renamedObj = {};
@@ -63,7 +50,7 @@ const renameKeys = (obj) => {
if (obj.center) {
renamedObj.locationCenter = {
lat: obj.center.lat,
lng: obj.center.lng,
lng: obj.center.lng
};
}
@@ -83,7 +70,7 @@ const keysToRemove = [
"_pinswg_associatedlpa_value@Microsoft.Dynamics.CRM.lookuplogicalname",
"_pinswg_appellant_value@Microsoft.Dynamics.CRM.lookuplogicalname",
"pinswg_anticipatedgridrefeasting@OData.Community.Display.V1.FormattedValue",
"pinswg_anticipatedgridrefnorthing@OData.Community.Display.V1.FormattedValue",
"pinswg_anticipatedgridrefnorthing@OData.Community.Display.V1.FormattedValue"
// Add any other keys to remove here
];
@@ -151,7 +138,7 @@ export default async function ApiProxy(req, res) {
: parseFloat(siteCoords.latitude),
lng: isNaN(parseFloat(siteCoords.longitude))
? -3.437989
: parseFloat(siteCoords.longitude),
: parseFloat(siteCoords.longitude)
};
});
@@ -159,7 +146,7 @@ export default async function ApiProxy(req, res) {
const updatedData = {
value: coordsObj.value.map((item) => renameKeys(item)),
"@odata.count": coordsObj["@odata.count"],
"@odata.count": coordsObj["@odata.count"]
};
return req.query.hasOwnProperty("fordmw")