refactor phase 3a api-endpoint chunk 5a targeted actions imports
This commit is contained in:
@@ -24,7 +24,9 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import CryptoJS from "crypto-js";
|
import CryptoJS from "crypto-js";
|
||||||
import _ from "lodash";
|
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;
|
const WORDKEY = process.env.HASHKEY;
|
||||||
|
|
||||||
@@ -58,23 +60,23 @@ export default async function ApiProxy(req, res) {
|
|||||||
var apiResponse = _.isEmpty(req.query)
|
var apiResponse = _.isEmpty(req.query)
|
||||||
? res.status(400).json()
|
? res.status(400).json()
|
||||||
: typeof emailAddress != "undefined" &&
|
: typeof emailAddress != "undefined" &&
|
||||||
emailAddress.length > 0 &&
|
emailAddress.length > 0 &&
|
||||||
typeof pwd != "undefined" &&
|
typeof pwd != "undefined" &&
|
||||||
pwd.length > 0
|
pwd.length > 0
|
||||||
? axios
|
? axios
|
||||||
.get(
|
.get(
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||||
azureHeadersPaged(token.access_token)
|
azureHeadersPaged(token.access_token)
|
||||||
)
|
)
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
res.status(400).json(error);
|
res.status(400).json(error);
|
||||||
})
|
})
|
||||||
: res.status(400).json();
|
: res.status(400).json();
|
||||||
|
|
||||||
return apiResponse;
|
return apiResponse;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import CryptoJS from "crypto-js";
|
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;
|
const WORDKEY = process.env.HASHKEY;
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import CryptoJS from "crypto-js";
|
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;
|
const WORDKEY = process.env.HASHKEY;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import CryptoJS from "crypto-js";
|
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;
|
const WORDKEY = process.env.HASHKEY;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import CryptoJS from "crypto-js";
|
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;
|
const WORDKEY = process.env.HASHKEY;
|
||||||
|
|
||||||
@@ -11,7 +13,7 @@ const WEBAPI_URL =
|
|||||||
const hashAPIPath = (queryPath) => {
|
const hashAPIPath = (queryPath) => {
|
||||||
var hashlink = CryptoJS.HmacSHA256(
|
var hashlink = CryptoJS.HmacSHA256(
|
||||||
queryPath,
|
queryPath,
|
||||||
CryptoJS.enc.Hex.parse(WORDKEY),
|
CryptoJS.enc.Hex.parse(WORDKEY)
|
||||||
);
|
);
|
||||||
hashlink = hashlink.toString(CryptoJS.enc.Hex);
|
hashlink = hashlink.toString(CryptoJS.enc.Hex);
|
||||||
|
|
||||||
@@ -70,7 +72,7 @@ export default function ApiProx(req, res) {
|
|||||||
"pinswg_mediaLinkEN":
|
"pinswg_mediaLinkEN":
|
||||||
"https://www.youtube.com/watch?v=H7S6CfF_7PI",
|
"https://www.youtube.com/watch?v=H7S6CfF_7PI",
|
||||||
"pinswg_mediaLinkCY":
|
"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":
|
"pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue":
|
||||||
@@ -93,7 +95,7 @@ export default function ApiProx(req, res) {
|
|||||||
"pinswg_mediaLinkEN":
|
"pinswg_mediaLinkEN":
|
||||||
"https://www.youtube.com/watch?v=OhxeLV_jPyE",
|
"https://www.youtube.com/watch?v=OhxeLV_jPyE",
|
||||||
"pinswg_mediaLinkCY":
|
"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":
|
"pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue":
|
||||||
@@ -117,7 +119,7 @@ export default function ApiProx(req, res) {
|
|||||||
"pinswg_mediaLinkEN":
|
"pinswg_mediaLinkEN":
|
||||||
"https://www.youtube.com/watch?v=9nsmadjgW94",
|
"https://www.youtube.com/watch?v=9nsmadjgW94",
|
||||||
"pinswg_mediaLinkCY":
|
"pinswg_mediaLinkCY":
|
||||||
"https://www.youtube.com/watch?v=9nsmadjgW94",
|
"https://www.youtube.com/watch?v=9nsmadjgW94"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue":
|
"pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue":
|
||||||
@@ -141,9 +143,9 @@ export default function ApiProx(req, res) {
|
|||||||
"pinswg_mediaLinkEN":
|
"pinswg_mediaLinkEN":
|
||||||
"https://www.youtube.com/watch?v=tRW3tm2Mby8",
|
"https://www.youtube.com/watch?v=tRW3tm2Mby8",
|
||||||
"pinswg_mediaLinkCY":
|
"pinswg_mediaLinkCY":
|
||||||
"https://www.youtube.com/watch?v=tRW3tm2Mby8",
|
"https://www.youtube.com/watch?v=tRW3tm2Mby8"
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
};
|
};
|
||||||
return res.status(200).json(data);
|
return res.status(200).json(data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,8 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import CryptoJS from "crypto-js";
|
import CryptoJS from "crypto-js";
|
||||||
import _ from "lodash";
|
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;
|
const WORDKEY = process.env.HASHKEY;
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ export default async function ApiProxy(req, res) {
|
|||||||
var token = await getToken();
|
var token = await getToken();
|
||||||
|
|
||||||
var data = JSON.stringify({
|
var data = JSON.stringify({
|
||||||
"servicestage": 0,
|
"servicestage": 0
|
||||||
});
|
});
|
||||||
|
|
||||||
//console.log(data, WEBAPI_URL + queryUrl);
|
//console.log(data, WEBAPI_URL + queryUrl);
|
||||||
@@ -53,9 +54,9 @@ export default async function ApiProxy(req, res) {
|
|||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||||
"Authorization": "Bearer " + token.access_token,
|
"Authorization": "Bearer " + token.access_token,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
data: data,
|
data: data
|
||||||
};
|
};
|
||||||
|
|
||||||
var apiResponse = _.isEmpty(req.query)
|
var apiResponse = _.isEmpty(req.query)
|
||||||
|
|||||||
Reference in New Issue
Block a user