refactor(actions): migrate endpoint and file proxies to focused imports
This commit is contained in:
@@ -43,32 +43,16 @@
|
||||
*/
|
||||
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
import _ from "lodash";
|
||||
import {
|
||||
azureHeadersPagedCustom,
|
||||
getToken,
|
||||
consoleLogger,
|
||||
} from "../../../actions";
|
||||
|
||||
const WORDKEY = process.env.HASHKEY;
|
||||
import { azureHeadersPagedCustom } from "../../../actions/core/headers";
|
||||
import { getToken } from "../../../actions/core/token";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
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;
|
||||
//console.log(hashlink);
|
||||
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
|
||||
};
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
var pageNumber = req.query.pageNumber;
|
||||
var token = await getToken();
|
||||
|
||||
@@ -43,30 +43,16 @@
|
||||
*/
|
||||
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
import _ from "lodash";
|
||||
import {
|
||||
azureHeadersPagedCustom,
|
||||
consoleLogger,
|
||||
getToken,
|
||||
} from "../../../actions";
|
||||
|
||||
const WORDKEY = process.env.HASHKEY;
|
||||
import { azureHeadersPagedCustom } from "../../../actions/core/headers";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import { getToken } from "../../../actions/core/token";
|
||||
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 (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
|
||||
};
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
var searchString = req.query.searchString;
|
||||
var pageNumber = req.query.pageNumber;
|
||||
|
||||
@@ -18,30 +18,17 @@
|
||||
*/
|
||||
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
import { JSONPath as jsonpath } from "jsonpath-plus";
|
||||
import {
|
||||
azureHeaders,
|
||||
consoleLogger,
|
||||
getLPA,
|
||||
getToken,
|
||||
} from "../../../actions";
|
||||
|
||||
const WORDKEY = process.env.HASHKEY;
|
||||
import { getLPA } from "../../../actions/services/referenceDataService";
|
||||
import { azureHeaders } from "../../../actions/core/headers";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import { getToken } from "../../../actions/core/token";
|
||||
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 (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
|
||||
};
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
var lpaid = req.query.lpaid;
|
||||
var token = await getToken();
|
||||
@@ -51,7 +38,7 @@ export default async function ApiProxy(req, res) {
|
||||
const lpaGUID = jsonpath({
|
||||
path: '$..[?(@ && @.name=="' + lpaid + '")]',
|
||||
json: lpaList,
|
||||
eval: true,
|
||||
eval: true
|
||||
});
|
||||
|
||||
//console.log(
|
||||
|
||||
@@ -45,11 +45,10 @@
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
import _ from "lodash";
|
||||
import {
|
||||
azureHeadersPagedCustom,
|
||||
consoleLogger,
|
||||
getToken,
|
||||
} from "../../../actions";
|
||||
import { azureHeadersPagedCustom } from "../../../actions/core/headers";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import { getToken } from "../../../actions/core/token";
|
||||
import { hashAPIPath } from "../../../actions/core/hash";
|
||||
|
||||
const WORDKEY = process.env.HASHKEY;
|
||||
|
||||
@@ -57,18 +56,6 @@ 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 encryptDocReference = (documentRef) => {
|
||||
var hashlink = CryptoJS.HmacSHA256(
|
||||
"documents/download/" + documentRef,
|
||||
@@ -158,7 +145,7 @@ export default async function ApiProxy(req, res) {
|
||||
"pinswg_documentpublisheddate":
|
||||
element.pinswg_documentpublisheddate != null
|
||||
? element.pinswg_documentpublisheddate
|
||||
: element.pinswg_latestpublisheddate,
|
||||
: element.pinswg_latestpublisheddate
|
||||
});
|
||||
element.pinswg_hashlink = encryptDocReference(
|
||||
element.pinswg_isharedocumentreference
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import {
|
||||
hashAPIPath,
|
||||
getToken,
|
||||
azureHeaders,
|
||||
consoleLogger,
|
||||
} from "../../../actions";
|
||||
import { hashAPIPath } from "../../../actions/core/hash";
|
||||
import { getToken } from "../../../actions/core/token";
|
||||
import { azureHeaders } from "../../../actions/core/headers";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import {
|
||||
getBlobs,
|
||||
createCaseCompleteMessage,
|
||||
createCaseCompleteMessage
|
||||
} from "../../../actions/azurestorage";
|
||||
import axios from "axios";
|
||||
|
||||
@@ -35,7 +33,7 @@ ApiProxy.get(async (req, res) => {
|
||||
|
||||
var config = {
|
||||
method: "get",
|
||||
url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl)
|
||||
};
|
||||
|
||||
return axios(config)
|
||||
@@ -53,8 +51,8 @@ ApiProxy.get(async (req, res) => {
|
||||
|
||||
export const config = {
|
||||
api: {
|
||||
bodyParser: false,
|
||||
},
|
||||
bodyParser: false
|
||||
}
|
||||
};
|
||||
|
||||
export default ApiProxy;
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import {
|
||||
downloadAllProgressFiles,
|
||||
getAllProgressBlobs,
|
||||
getAllProgressBlobs
|
||||
} from "../../../actions/azurestorage";
|
||||
import _ from "lodash";
|
||||
import nextConnect from "next-connect";
|
||||
import middleware from "../middleware/middleware";
|
||||
import {
|
||||
getToken,
|
||||
azureHeaders,
|
||||
consoleLogger,
|
||||
hashAPIPath,
|
||||
} from "../../../actions";
|
||||
import { getToken } from "../../../actions/core/token";
|
||||
import { azureHeaders } from "../../../actions/core/headers";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import { hashAPIPath } from "../../../actions/core/hash";
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import {
|
||||
downloadAllProgressFiles,
|
||||
getAllProgressBlobs,
|
||||
getAllProgressBlobs
|
||||
} from "../../../actions/azurestorage";
|
||||
import _ from "lodash";
|
||||
import nextConnect from "next-connect";
|
||||
import middleware from "../middleware/middleware";
|
||||
import {
|
||||
getToken,
|
||||
azureHeaders,
|
||||
consoleLogger,
|
||||
hashAPIPath,
|
||||
} from "../../../actions";
|
||||
import { getToken } from "../../../actions/core/token";
|
||||
import { azureHeaders } from "../../../actions/core/headers";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import { hashAPIPath } from "../../../actions/core/hash";
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import {
|
||||
downloadAllProgressFiles,
|
||||
getAllProgressBlobs,
|
||||
getAllProgressBlobs
|
||||
} from "../../../actions/azurestorage";
|
||||
import _ from "lodash";
|
||||
import nextConnect from "next-connect";
|
||||
import middleware from "../middleware/middleware";
|
||||
import {
|
||||
getToken,
|
||||
azureHeaders,
|
||||
consoleLogger,
|
||||
hashAPIPath,
|
||||
} from "../../../actions";
|
||||
import { getToken } from "../../../actions/core/token";
|
||||
import { azureHeaders } from "../../../actions/core/headers";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import { hashAPIPath } from "../../../actions/core/hash";
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user