updated with oauth, footer docs,

This commit is contained in:
2021-11-30 07:22:07 +00:00
parent f9f7b777e7
commit af5354d19f
32 changed files with 4790 additions and 250 deletions
+30 -18
View File
@@ -70,28 +70,38 @@ function checkProxyPath(queryPath) {
}
export default async function ApiProxy(req, res) {
var data = JSON.stringify(req.body);
var data = req.body; //JSON.stringify(req.body);
var accessToken = await getToken();
accessToken = accessToken.access_token;
const isDocument = req.url.indexOf("/documents/download") > -1;
let hashCheckPath = isDocument
? req.url.split("?hash=")[0]
: req.url.split("&hash=")[0];
let hashCheckValue = isDocument
? req.url.split("?hash=")[1]
: req.url.split("&hash=")[1];
let hashCheckPath =
req.url.indexOf("?hash=") > -1
? req.url.split("?hash=")[0]
: req.url.split("&hash=")[0];
let hashCheckValue =
req.url.indexOf("?hash=") > -1
? req.url.split("?hash=")[1]
: req.url.split("&hash=")[1];
let hashFromRequest = checkProxyPath(hashCheckPath);
let proxyDestinationURL =
PROXY_RELAY_URL +
(req.url.indexOf("?hash=") > -1
? req.url.split("?hash=")[0]
: req.url.split("&hash=")[0]
).split("/api/proxy/")[1] +
(req.url.indexOf("?hash=") > -1
? "?hash=" + req.url.split("?hash=")[1]
: "&hash=" + req.url.split("&hash=")[1]);
var configNoData = {
method: req.method,
//url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")",
url:
PROXY_RELAY_URL +
req.url.split("&hash=")[0].split("/api/proxy/")[1] +
"&hash=" +
req.url.split("&hash=")[1],
url: proxyDestinationURL,
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
@@ -105,11 +115,7 @@ export default async function ApiProxy(req, res) {
var config = {
method: req.method,
url:
PROXY_RELAY_URL +
req.query.route[0] +
"&hash=" +
req.url.split("&hash=")[1],
url: proxyDestinationURL,
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
@@ -145,7 +151,9 @@ export default async function ApiProxy(req, res) {
hashCheckPath.indexOf("/download") > 0 ? true : false;
axios(
req.method == "GET"
req.method == "PATCH"
? config
: req.method == "GET"
? hasDocument
? configDocument
: configNoData
@@ -177,6 +185,10 @@ export default async function ApiProxy(req, res) {
});
});
} else {
console.log(
"no matching hash",
hashCheckValue + " - " + hashFromRequest
);
res.status(405).end();
return resolve();
}