refactor(api): migrate batch 12 remaining relay-get candidates
This commit is contained in:
@@ -1,14 +1,7 @@
|
||||
import axios from "axios";
|
||||
import { azureHeaders } from "../../../actions/core/headers";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import { getToken } from "../../../actions/core/token";
|
||||
import OSPoint from "ospoint";
|
||||
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 { relayGetData } from "../middleware/relayForwarding";
|
||||
|
||||
const renameKeys = (obj) => {
|
||||
const keyMappings = {
|
||||
@@ -75,8 +68,6 @@ const keysToRemove = [
|
||||
];
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
const token = await getToken();
|
||||
|
||||
const queryUrl =
|
||||
"pinswg_dnses?$select=pinswg_projectlocation,pinswg_mapzoomlevel,pinswg_name,pinswg_anticipatedgridreferenceeastingtext,pinswg_anticipatedgridreferencenorthingtext,pinswg_projectname,pinswg_dnsid,_pinswg_associatedlpa_value,_pinswg_appellant_value&$filter=pinswg_anticipatedgridreferencenorthingtext ne null and pinswg_anticipatedgridreferenceeastingtext ne null&$count=true";
|
||||
|
||||
@@ -87,11 +78,8 @@ export default async function ApiProxy(req, res) {
|
||||
const coordsObj = { value: [] };
|
||||
|
||||
try {
|
||||
// First Axios request
|
||||
const dnsCoordsObj = await axios.get(
|
||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
azureHeaders(token.access_token)
|
||||
);
|
||||
// First relay request
|
||||
const dnsCoordsObj = await relayGetData({ queryUrl });
|
||||
// Merge the first response's 'value' array into the coordsObj's value array
|
||||
if (Array.isArray(dnsCoordsObj.data.value)) {
|
||||
coordsObj.value = coordsObj.value.concat(dnsCoordsObj.data.value); // Concatenate arrays
|
||||
@@ -99,11 +87,8 @@ export default async function ApiProxy(req, res) {
|
||||
coordsObj.value.push(dnsCoordsObj.data.value); // Push single value if it's not an array
|
||||
}
|
||||
|
||||
// Second Axios request
|
||||
const sipsCoordsObj = await axios.get(
|
||||
WEBAPI_URL + queryUrlSips + hashAPIPath(queryUrlSips),
|
||||
azureHeaders(token.access_token)
|
||||
);
|
||||
// Second relay request
|
||||
const sipsCoordsObj = await relayGetData({ queryUrl: queryUrlSips });
|
||||
// Merge the second response's 'value' array into the coordsObj's value array
|
||||
if (Array.isArray(sipsCoordsObj.data.value)) {
|
||||
coordsObj.value = coordsObj.value.concat(sipsCoordsObj.data.value); // Concatenate arrays
|
||||
|
||||
Reference in New Issue
Block a user