From 2a3c7eac34c01618faa0d268565fa70cba8acb8b Mon Sep 17 00:00:00 2001 From: robbond Date: Thu, 12 Mar 2026 11:31:38 +0000 Subject: [PATCH] refactor phase 3a api-endpoint chunk 5a targeted actions imports --- pages/api/endpoint/getlogin_api.js | 38 ++++++++++--------- pages/api/endpoint/getrepresentations_api.js | 4 +- .../endpoint/getrepresentationsproxy_api.js | 4 +- pages/api/endpoint/getsipsevents_api.js | 4 +- pages/api/endpoint/getsipsmedia_api.js | 18 +++++---- pages/api/endpoint/patchcase_api.js | 9 +++-- 6 files changed, 44 insertions(+), 33 deletions(-) diff --git a/pages/api/endpoint/getlogin_api.js b/pages/api/endpoint/getlogin_api.js index 1f0f4559..08a738c0 100644 --- a/pages/api/endpoint/getlogin_api.js +++ b/pages/api/endpoint/getlogin_api.js @@ -24,7 +24,9 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { azureHeadersPaged, consoleLogger, getToken } from "../../../actions"; +import { azureHeadersPaged } from "../../../actions/core/headers"; +import { consoleLogger } from "../../../actions/core/logger"; +import { getToken } from "../../../actions/core/token"; const WORDKEY = process.env.HASHKEY; @@ -58,23 +60,23 @@ export default async function ApiProxy(req, res) { var apiResponse = _.isEmpty(req.query) ? res.status(400).json() : typeof emailAddress != "undefined" && - emailAddress.length > 0 && - typeof pwd != "undefined" && - pwd.length > 0 - ? axios - .get( - WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), - azureHeadersPaged(token.access_token) - ) - .then(({ data }) => { - console.log(data); - res.status(200).json(data); - }) - .catch((error) => { - consoleLogger(error); - res.status(400).json(error); - }) - : res.status(400).json(); + emailAddress.length > 0 && + typeof pwd != "undefined" && + pwd.length > 0 + ? axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + console.log(data); + res.status(200).json(data); + }) + .catch((error) => { + consoleLogger(error); + res.status(400).json(error); + }) + : res.status(400).json(); return apiResponse; } diff --git a/pages/api/endpoint/getrepresentations_api.js b/pages/api/endpoint/getrepresentations_api.js index c59249c4..1b037140 100644 --- a/pages/api/endpoint/getrepresentations_api.js +++ b/pages/api/endpoint/getrepresentations_api.js @@ -19,7 +19,9 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { azureHeaders, consoleLogger, getToken } from "../../../actions"; +import { azureHeaders } from "../../../actions/core/headers"; +import { consoleLogger } from "../../../actions/core/logger"; +import { getToken } from "../../../actions/core/token"; const WORDKEY = process.env.HASHKEY; diff --git a/pages/api/endpoint/getrepresentationsproxy_api.js b/pages/api/endpoint/getrepresentationsproxy_api.js index 4c535208..eec1ab40 100644 --- a/pages/api/endpoint/getrepresentationsproxy_api.js +++ b/pages/api/endpoint/getrepresentationsproxy_api.js @@ -19,7 +19,9 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { azureHeaders, consoleLogger, getToken } from "../../../actions"; +import { azureHeaders } from "../../../actions/core/headers"; +import { consoleLogger } from "../../../actions/core/logger"; +import { getToken } from "../../../actions/core/token"; const WORDKEY = process.env.HASHKEY; diff --git a/pages/api/endpoint/getsipsevents_api.js b/pages/api/endpoint/getsipsevents_api.js index 5311aa6e..db483781 100644 --- a/pages/api/endpoint/getsipsevents_api.js +++ b/pages/api/endpoint/getsipsevents_api.js @@ -1,6 +1,8 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { azureHeaders, consoleLogger, getToken } from "../../../actions"; +import { azureHeaders } from "../../../actions/core/headers"; +import { consoleLogger } from "../../../actions/core/logger"; +import { getToken } from "../../../actions/core/token"; const WORDKEY = process.env.HASHKEY; diff --git a/pages/api/endpoint/getsipsmedia_api.js b/pages/api/endpoint/getsipsmedia_api.js index 37b119cd..b1baa6c6 100644 --- a/pages/api/endpoint/getsipsmedia_api.js +++ b/pages/api/endpoint/getsipsmedia_api.js @@ -1,6 +1,8 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { azureHeaders, consoleLogger, getToken } from "../../../actions"; +import { azureHeaders } from "../../../actions/core/headers"; +import { consoleLogger } from "../../../actions/core/logger"; +import { getToken } from "../../../actions/core/token"; const WORDKEY = process.env.HASHKEY; @@ -11,7 +13,7 @@ const WEBAPI_URL = const hashAPIPath = (queryPath) => { var hashlink = CryptoJS.HmacSHA256( queryPath, - CryptoJS.enc.Hex.parse(WORDKEY), + CryptoJS.enc.Hex.parse(WORDKEY) ); hashlink = hashlink.toString(CryptoJS.enc.Hex); @@ -70,7 +72,7 @@ export default function ApiProx(req, res) { "pinswg_mediaLinkEN": "https://www.youtube.com/watch?v=H7S6CfF_7PI", "pinswg_mediaLinkCY": - "https://www.youtube.com/watch?v=H7S6CfF_7PI", + "https://www.youtube.com/watch?v=H7S6CfF_7PI" }, { "pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue": @@ -93,7 +95,7 @@ export default function ApiProx(req, res) { "pinswg_mediaLinkEN": "https://www.youtube.com/watch?v=OhxeLV_jPyE", "pinswg_mediaLinkCY": - "https://www.youtube.com/watch?v=OhxeLV_jPyE", + "https://www.youtube.com/watch?v=OhxeLV_jPyE" }, { "pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue": @@ -117,7 +119,7 @@ export default function ApiProx(req, res) { "pinswg_mediaLinkEN": "https://www.youtube.com/watch?v=9nsmadjgW94", "pinswg_mediaLinkCY": - "https://www.youtube.com/watch?v=9nsmadjgW94", + "https://www.youtube.com/watch?v=9nsmadjgW94" }, { "pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue": @@ -141,9 +143,9 @@ export default function ApiProx(req, res) { "pinswg_mediaLinkEN": "https://www.youtube.com/watch?v=tRW3tm2Mby8", "pinswg_mediaLinkCY": - "https://www.youtube.com/watch?v=tRW3tm2Mby8", - }, - ], + "https://www.youtube.com/watch?v=tRW3tm2Mby8" + } + ] }; return res.status(200).json(data); } diff --git a/pages/api/endpoint/patchcase_api.js b/pages/api/endpoint/patchcase_api.js index c61f8c6c..72be4972 100644 --- a/pages/api/endpoint/patchcase_api.js +++ b/pages/api/endpoint/patchcase_api.js @@ -13,7 +13,8 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { consoleLogger, getToken } from "../../../actions"; +import { consoleLogger } from "../../../actions/core/logger"; +import { getToken } from "../../../actions/core/token"; const WORDKEY = process.env.HASHKEY; @@ -39,7 +40,7 @@ export default async function ApiProxy(req, res) { var token = await getToken(); var data = JSON.stringify({ - "servicestage": 0, + "servicestage": 0 }); //console.log(data, WEBAPI_URL + queryUrl); @@ -53,9 +54,9 @@ export default async function ApiProxy(req, res) { "Accept": "application/json", "Prefer": 'odata.include-annotations="*",return=representation', "Authorization": "Bearer " + token.access_token, - "Content-Type": "application/json", + "Content-Type": "application/json" }, - data: data, + data: data }; var apiResponse = _.isEmpty(req.query)