TASK22211: normalize dns and representation endpoint contracts
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
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 ||
|
||||
@@ -75,16 +75,16 @@ const keysToRemove = [
|
||||
];
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
var token = await getToken();
|
||||
const token = await getToken();
|
||||
|
||||
var queryUrl =
|
||||
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";
|
||||
|
||||
//console.log("dns ", queryUrl);
|
||||
var queryUrlSips =
|
||||
const queryUrlSips =
|
||||
"pinswg_sipses?$select=pinswg_projectlocation,pinswg_mapzoomlevel,pinswg_name,pinswg_anticipatedgridrefeasting,pinswg_anticipatedgridrefnorthing,pinswg_projectname,pinswg_sipscase,_pinswg_associatedlpa_value,_pinswg_appellant_value&$filter=pinswg_anticipatedgridrefeasting ne null and pinswg_anticipatedgridrefnorthing ne null&$count=true";
|
||||
|
||||
var coordsObj = { value: [] };
|
||||
const coordsObj = { value: [] };
|
||||
|
||||
try {
|
||||
// First Axios request
|
||||
@@ -150,11 +150,15 @@ export default async function ApiProxy(req, res) {
|
||||
};
|
||||
|
||||
return req.query.hasOwnProperty("fordmw")
|
||||
? res.status(200).json(updatedData)
|
||||
: res.status(200).json(coordsObj);
|
||||
? respondSuccess(res, updatedData)
|
||||
: respondSuccess(res, coordsObj);
|
||||
} catch (error) {
|
||||
// Catch any errors and send an error response
|
||||
consoleLogger(error);
|
||||
return res.status(400).json(error);
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "DNS_COORDS_FETCH_FAILED",
|
||||
message: "Failed to fetch DNS coordinates"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user