refactor(actions): migrate endpoint and file proxies to focused imports

This commit is contained in:
2026-03-12 17:39:50 +00:00
parent f0202bbd02
commit fa985351ff
8 changed files with 42 additions and 106 deletions
@@ -43,32 +43,16 @@
*/ */
import axios from "axios"; import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash"; import _ from "lodash";
import { import { azureHeadersPagedCustom } from "../../../actions/core/headers";
azureHeadersPagedCustom, import { getToken } from "../../../actions/core/token";
getToken, import { consoleLogger } from "../../../actions/core/logger";
consoleLogger, import { hashAPIPath } from "../../../actions/core/hash";
} from "../../../actions";
const WORDKEY = process.env.HASHKEY;
const WEBAPI_URL = const WEBAPI_URL =
process.env.RELAY_ROOT || process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; "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;
//console.log(hashlink);
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) { export default async function ApiProxy(req, res) {
var pageNumber = req.query.pageNumber; var pageNumber = req.query.pageNumber;
var token = await getToken(); var token = await getToken();
+4 -18
View File
@@ -43,30 +43,16 @@
*/ */
import axios from "axios"; import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash"; import _ from "lodash";
import { import { azureHeadersPagedCustom } from "../../../actions/core/headers";
azureHeadersPagedCustom, import { consoleLogger } from "../../../actions/core/logger";
consoleLogger, import { getToken } from "../../../actions/core/token";
getToken, import { hashAPIPath } from "../../../actions/core/hash";
} from "../../../actions";
const WORDKEY = process.env.HASHKEY;
const WEBAPI_URL = const WEBAPI_URL =
process.env.RELAY_ROOT || process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; "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 (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) { export default async function ApiProxy(req, res) {
var searchString = req.query.searchString; var searchString = req.query.searchString;
var pageNumber = req.query.pageNumber; var pageNumber = req.query.pageNumber;
+6 -19
View File
@@ -18,30 +18,17 @@
*/ */
import axios from "axios"; import axios from "axios";
import CryptoJS from "crypto-js";
import { JSONPath as jsonpath } from "jsonpath-plus"; import { JSONPath as jsonpath } from "jsonpath-plus";
import { import { getLPA } from "../../../actions/services/referenceDataService";
azureHeaders, import { azureHeaders } from "../../../actions/core/headers";
consoleLogger, import { consoleLogger } from "../../../actions/core/logger";
getLPA, import { getToken } from "../../../actions/core/token";
getToken, import { hashAPIPath } from "../../../actions/core/hash";
} from "../../../actions";
const WORDKEY = process.env.HASHKEY;
const WEBAPI_URL = const WEBAPI_URL =
process.env.RELAY_ROOT || process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; "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 (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) { export default async function ApiProxy(req, res) {
var lpaid = req.query.lpaid; var lpaid = req.query.lpaid;
var token = await getToken(); var token = await getToken();
@@ -51,7 +38,7 @@ export default async function ApiProxy(req, res) {
const lpaGUID = jsonpath({ const lpaGUID = jsonpath({
path: '$..[?(@ && @.name=="' + lpaid + '")]', path: '$..[?(@ && @.name=="' + lpaid + '")]',
json: lpaList, json: lpaList,
eval: true, eval: true
}); });
//console.log( //console.log(
@@ -45,11 +45,10 @@
import axios from "axios"; import axios from "axios";
import CryptoJS from "crypto-js"; import CryptoJS from "crypto-js";
import _ from "lodash"; import _ from "lodash";
import { import { azureHeadersPagedCustom } from "../../../actions/core/headers";
azureHeadersPagedCustom, import { consoleLogger } from "../../../actions/core/logger";
consoleLogger, import { getToken } from "../../../actions/core/token";
getToken, import { hashAPIPath } from "../../../actions/core/hash";
} from "../../../actions";
const WORDKEY = process.env.HASHKEY; const WORDKEY = process.env.HASHKEY;
@@ -57,18 +56,6 @@ const WEBAPI_URL =
process.env.RELAY_ROOT || process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; "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 encryptDocReference = (documentRef) => { const encryptDocReference = (documentRef) => {
var hashlink = CryptoJS.HmacSHA256( var hashlink = CryptoJS.HmacSHA256(
"documents/download/" + documentRef, "documents/download/" + documentRef,
@@ -158,7 +145,7 @@ export default async function ApiProxy(req, res) {
"pinswg_documentpublisheddate": "pinswg_documentpublisheddate":
element.pinswg_documentpublisheddate != null element.pinswg_documentpublisheddate != null
? element.pinswg_documentpublisheddate ? element.pinswg_documentpublisheddate
: element.pinswg_latestpublisheddate, : element.pinswg_latestpublisheddate
}); });
element.pinswg_hashlink = encryptDocReference( element.pinswg_hashlink = encryptDocReference(
element.pinswg_isharedocumentreference element.pinswg_isharedocumentreference
@@ -1,12 +1,10 @@
import { import { hashAPIPath } from "../../../actions/core/hash";
hashAPIPath, import { getToken } from "../../../actions/core/token";
getToken, import { azureHeaders } from "../../../actions/core/headers";
azureHeaders, import { consoleLogger } from "../../../actions/core/logger";
consoleLogger,
} from "../../../actions";
import { import {
getBlobs, getBlobs,
createCaseCompleteMessage, createCaseCompleteMessage
} from "../../../actions/azurestorage"; } from "../../../actions/azurestorage";
import axios from "axios"; import axios from "axios";
@@ -35,7 +33,7 @@ ApiProxy.get(async (req, res) => {
var config = { var config = {
method: "get", method: "get",
url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl)
}; };
return axios(config) return axios(config)
@@ -53,8 +51,8 @@ ApiProxy.get(async (req, res) => {
export const config = { export const config = {
api: { api: {
bodyParser: false, bodyParser: false
}, }
}; };
export default ApiProxy; export default ApiProxy;
@@ -1,16 +1,14 @@
import { import {
downloadAllProgressFiles, downloadAllProgressFiles,
getAllProgressBlobs, getAllProgressBlobs
} from "../../../actions/azurestorage"; } from "../../../actions/azurestorage";
import _ from "lodash"; import _ from "lodash";
import nextConnect from "next-connect"; import nextConnect from "next-connect";
import middleware from "../middleware/middleware"; import middleware from "../middleware/middleware";
import { import { getToken } from "../../../actions/core/token";
getToken, import { azureHeaders } from "../../../actions/core/headers";
azureHeaders, import { consoleLogger } from "../../../actions/core/logger";
consoleLogger, import { hashAPIPath } from "../../../actions/core/hash";
hashAPIPath,
} from "../../../actions";
import axios from "axios"; import axios from "axios";
import CryptoJS from "crypto-js"; import CryptoJS from "crypto-js";
+5 -7
View File
@@ -1,16 +1,14 @@
import { import {
downloadAllProgressFiles, downloadAllProgressFiles,
getAllProgressBlobs, getAllProgressBlobs
} from "../../../actions/azurestorage"; } from "../../../actions/azurestorage";
import _ from "lodash"; import _ from "lodash";
import nextConnect from "next-connect"; import nextConnect from "next-connect";
import middleware from "../middleware/middleware"; import middleware from "../middleware/middleware";
import { import { getToken } from "../../../actions/core/token";
getToken, import { azureHeaders } from "../../../actions/core/headers";
azureHeaders, import { consoleLogger } from "../../../actions/core/logger";
consoleLogger, import { hashAPIPath } from "../../../actions/core/hash";
hashAPIPath,
} from "../../../actions";
import axios from "axios"; import axios from "axios";
import CryptoJS from "crypto-js"; import CryptoJS from "crypto-js";
+5 -7
View File
@@ -1,16 +1,14 @@
import { import {
downloadAllProgressFiles, downloadAllProgressFiles,
getAllProgressBlobs, getAllProgressBlobs
} from "../../../actions/azurestorage"; } from "../../../actions/azurestorage";
import _ from "lodash"; import _ from "lodash";
import nextConnect from "next-connect"; import nextConnect from "next-connect";
import middleware from "../middleware/middleware"; import middleware from "../middleware/middleware";
import { import { getToken } from "../../../actions/core/token";
getToken, import { azureHeaders } from "../../../actions/core/headers";
azureHeaders, import { consoleLogger } from "../../../actions/core/logger";
consoleLogger, import { hashAPIPath } from "../../../actions/core/hash";
hashAPIPath,
} from "../../../actions";
import axios from "axios"; import axios from "axios";
import CryptoJS from "crypto-js"; import CryptoJS from "crypto-js";