reps defects

This commit is contained in:
2024-06-03 11:57:11 +01:00
parent c63ea33c64
commit c947995e7b
19 changed files with 392 additions and 167 deletions
@@ -0,0 +1,69 @@
/**
* @swagger
* /api/endpoint/getportallogin_api:
* get:
* tags: [Login]
* description: Returns portal login
* summary: Phase 2
* parameters:
* - name: emailaddress
* in: query
* required: true
* schema:
* type: string
* responses:
* 200:
* description: hello world
*/
import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash";
import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions";
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 (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) {
var emailAddress = req.query.emailAddress;
var token = await getToken();
var queryUrl =
"contacts?$filter=emailaddress1 eq '" +
emailAddress +
"'&$count=true&$select=emailaddress1,contactid,yomifullname,firstname,lastname";
//console.log(req.query);
var apiResponse = _.isEmpty(req.query)
? res.status(400).json()
: typeof emailAddress != "undefined" && emailAddress.length > 0
? axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
//console.log(data);
res.status(200).json(data);
})
.catch((err) => {
console.log(consoleLogger(err));
res.status(400).json(err);
})
: res.status(400).json();
return apiResponse;
}
+4 -2
View File
@@ -36,7 +36,7 @@ import {
import _ from "lodash";
import nextConnect from "next-connect";
import middleware from "../middleware/middleware";
import { hashAPIPath } from "../../../actions";
import { consoleLogger, hashAPIPath } from "../../../actions";
const ApiProxy = nextConnect();
ApiProxy.use(middleware);
@@ -80,7 +80,9 @@ ApiProxy.get(async (req, res) => {
error +
"\n///////////////////////\n"
);
console.log("API call error", error);
//console.log("API call error", error);
console.log(consoleLogger(error));
});
} else {
return res.status(400).json({ msg: "error" });