152 lines
6.9 KiB
JavaScript
152 lines
6.9 KiB
JavaScript
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";
|
||
|
||
const WORDKEY = process.env.HASHKEY;
|
||
|
||
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;
|
||
};
|
||
|
||
// export default async function ApiProxy(req, res) {
|
||
// var caseid = req.query.caseid;
|
||
// var token = await getToken();
|
||
|
||
// var queryUrl =
|
||
// "pinswg_sipsevents?$filter=_pinswg_sipseventsid_value eq " +
|
||
// caseid +
|
||
// "&$count=true";
|
||
|
||
// return axios
|
||
// .get(
|
||
// WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||
// azureHeaders(token.access_token),
|
||
// )
|
||
// .then(({ data }) => {
|
||
// res.status(200).json(data);
|
||
// })
|
||
// .catch((error) => {
|
||
// consoleLogger(error);
|
||
// res.status(400).json(error);
|
||
// });
|
||
// }
|
||
|
||
export default function ApiProx(req, res) {
|
||
const data = {
|
||
"@odata.count": 4,
|
||
"value": [
|
||
{
|
||
"pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue":
|
||
"Yes",
|
||
"pinswg_publishtoweb": true,
|
||
"pinswg_uploadstatus": 846040000,
|
||
"pinswg_name":
|
||
"Puffin Paradise? Exploring Wales’ Cutest Wildlife Spot (Skomer Travel Guide)",
|
||
"pinswg_description":
|
||
"Skomer Island is a tiny uninhabited isle off the coast of Pembrokeshire in western Wales. Although it's just ten minutes from the mainland by ferry, it's home to over 40,000 puffins, the largest colony in the world of Manx Shearwaters, and lots of seals.",
|
||
"pinswg_latestpublishedversion": "1.0",
|
||
"pinswg_latestpublisheddate@OData.Community.Display.V1.FormattedValue":
|
||
"2/2/2026",
|
||
"pinswg_latestpublisheddate": "2026-02-02T10:20:46Z",
|
||
"pinswg_documentpublisheddate": "2026-02-02T10:20:46Z",
|
||
"pinswg_documentid": "9d4550b7-2000-f111-aa10-002248008e24",
|
||
"createdon@OData.Community.Display.V1.FormattedValue":
|
||
"2/2/2026 10:19 AM",
|
||
"createdon": "2026-02-02T10:19:55Z",
|
||
"pinswg_hashlink":
|
||
"/api/documents/download/A22258739?hash=51d64c1330ed2fe1fb9aff4658b8eedadf1b062d2b0313b39bc5af786228324b",
|
||
"pinswg_mediaLinkEN":
|
||
"https://www.youtube.com/watch?v=H7S6CfF_7PI",
|
||
"pinswg_mediaLinkCY":
|
||
"https://www.youtube.com/watch?v=H7S6CfF_7PI"
|
||
},
|
||
{
|
||
"pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue":
|
||
"Yes",
|
||
"pinswg_publishtoweb": true,
|
||
"pinswg_uploadstatus": 846040000,
|
||
"pinswg_name": "Redstone Cross - side roads",
|
||
"pinswg_description": "Redstone Cross - side roads",
|
||
"pinswg_latestpublishedversion": "1.0",
|
||
"pinswg_latestpublisheddate@OData.Community.Display.V1.FormattedValue":
|
||
"2/2/2026",
|
||
"pinswg_latestpublisheddate": "2026-02-02T10:20:46Z",
|
||
"pinswg_documentpublisheddate": "2026-02-02T10:20:46Z",
|
||
"pinswg_documentid": "9d4550b7-2000-f111-aa10-002248008e24",
|
||
"createdon@OData.Community.Display.V1.FormattedValue":
|
||
"2/2/2026 10:19 AM",
|
||
"createdon": "2026-02-02T10:19:55Z",
|
||
"pinswg_hashlink":
|
||
"/api/documents/download/A22258739?hash=51d64c1330ed2fe1fb9aff4658b8eedadf1b062d2b0313b39bc5af786228324b",
|
||
"pinswg_mediaLinkEN":
|
||
"https://www.youtube.com/watch?v=OhxeLV_jPyE",
|
||
"pinswg_mediaLinkCY":
|
||
"https://www.youtube.com/watch?v=OhxeLV_jPyE"
|
||
},
|
||
{
|
||
"pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue":
|
||
"Yes",
|
||
"pinswg_publishtoweb": true,
|
||
"pinswg_uploadstatus": 846040000,
|
||
"pinswg_name":
|
||
"Apprenticeships: Dinorwig Power Station (bilingual)",
|
||
"pinswg_description": "blah blah blah",
|
||
"pinswg_latestpublishedversion": "1.0",
|
||
"pinswg_latestpublisheddate@OData.Community.Display.V1.FormattedValue":
|
||
"2/2/2026",
|
||
"pinswg_latestpublisheddate": "2026-02-02T10:20:46Z",
|
||
"pinswg_documentpublisheddate": "2026-02-02T10:20:46Z",
|
||
"pinswg_documentid": "9d4550b7-2000-f111-aa10-002248008e24",
|
||
"createdon@OData.Community.Display.V1.FormattedValue":
|
||
"2/2/2026 10:19 AM",
|
||
"createdon": "2026-02-02T10:19:55Z",
|
||
"pinswg_hashlink":
|
||
"/api/documents/download/A22258739?hash=51d64c1330ed2fe1fb9aff4658b8eedadf1b062d2b0313b39bc5af786228324b",
|
||
"pinswg_mediaLinkEN":
|
||
"https://www.youtube.com/watch?v=9nsmadjgW94",
|
||
"pinswg_mediaLinkCY":
|
||
"https://www.youtube.com/watch?v=9nsmadjgW94"
|
||
},
|
||
{
|
||
"pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue":
|
||
"Yes",
|
||
"pinswg_publishtoweb": true,
|
||
"pinswg_uploadstatus": 846040000,
|
||
"pinswg_name":
|
||
"Climate Action Wales - Cardiff Cycle Workshop - Sustainable Cycling in Cardiff",
|
||
"pinswg_description": "blah blah blah",
|
||
"pinswg_latestpublishedversion": "1.0",
|
||
"pinswg_latestpublisheddate@OData.Community.Display.V1.FormattedValue":
|
||
"2/2/2026",
|
||
"pinswg_latestpublisheddate": "2026-02-02T10:20:46Z",
|
||
"pinswg_documentpublisheddate": "2026-02-02T10:20:46Z",
|
||
"pinswg_documentid": "9d4550b7-2000-f111-aa10-002248008e24",
|
||
"createdon@OData.Community.Display.V1.FormattedValue":
|
||
"2/2/2026 10:19 AM",
|
||
"createdon": "2026-02-02T10:19:55Z",
|
||
"pinswg_hashlink":
|
||
"/api/documents/download/A22258739?hash=51d64c1330ed2fe1fb9aff4658b8eedadf1b062d2b0313b39bc5af786228324b",
|
||
"pinswg_mediaLinkEN":
|
||
"https://www.youtube.com/watch?v=tRW3tm2Mby8",
|
||
"pinswg_mediaLinkCY":
|
||
"https://www.youtube.com/watch?v=tRW3tm2Mby8"
|
||
}
|
||
]
|
||
};
|
||
return res.status(200).json(data);
|
||
}
|