Create function check status for other system

This commit is contained in:
joseph le 2023-10-11 15:23:03 +07:00
parent bb8f38c6ec
commit 3aff35bb15
1 changed files with 69 additions and 44 deletions

View File

@ -69,7 +69,7 @@ const checkMultipleRequest = async () => {
// },
// data: {},
// name: "Erp Sync Order Ebay",
// group: "Ebay Systems"
// group: "Ebay Systems",
// },
// {
// url: "https://disti.danielvu.com/api/sendBuyerOrderToERP",
@ -83,7 +83,7 @@ const checkMultipleRequest = async () => {
// },
// data: {},
// name: "Erp Sync PO Ebay",
// group: "Ebay Systems"
// group: "Ebay Systems",
// },
// //ERP Systems
// {
@ -98,7 +98,7 @@ const checkMultipleRequest = async () => {
// filter: {},
// },
// name: "Log SN to ERP",
// group: "ERP Systems"
// group: "ERP Systems",
// },
// {
// url: "https://int.ipsupply.com.au/api/transferGetData",
@ -459,11 +459,10 @@ const checkMultipleRequest = async () => {
// countryCode: "AU",
// },
// to: {
// streetLines: ["600 Terminal Dr"],
// city: "Louisville",
// stateOrProvinceCode: "KY",
// postalCode: "40209",
// countryCode: "US",
// streetLines: ["112 Munro St"],
// city: "South Melbourne",
// postalCode: "3205",
// countryCode: "AU",
// },
// requestedPackageLineItems: [
// {
@ -524,11 +523,10 @@ const checkMultipleRequest = async () => {
// countryCode: "AU",
// },
// to: {
// streetLines: ["600 Terminal Dr"],
// city: "Louisville",
// stateOrProvinceCode: "KY",
// postalCode: "40209",
// countryCode: "US",
// streetLines: ["112 Munro St"],
// city: "South Melbourne",
// postalCode: "3205",
// countryCode: "AU",
// },
// requestedPackageLineItems: [
// {
@ -764,14 +762,60 @@ const checkMultipleRequest = async () => {
lengthOrData: response.data?.data?.length | response.data,
});
} else {
if (Array.isArray(response.data.data) === false) {
const data = JSON.stringify(
response.data?.data
)?.toLocaleLowerCase();
if (response.data?.data !== undefined) {
if (Array.isArray(response.data.data) === false) {
const data = JSON.stringify(
response.data?.data
)?.toLocaleLowerCase();
if (
data?.includes("error") ||
data?.includes("invalid") ||
response.data.data === undefined
) {
report.push({
group: req.group,
name: req.name,
status: ":red_circle:",
code: response.status,
lengthOrData: JSON.stringify(response.data?.data),
});
} else {
report.push({
group: req.group,
name: req.name,
status: ":check:",
code: response.status,
lengthOrData: response.data?.data?.length,
});
}
} else {
if (
response.data?.data !== undefined &&
response.data?.data?.length > 0
) {
report.push({
group: req.group,
name: req.name,
status: ":check:",
code: response.status,
lengthOrData: response.data?.data?.length,
});
} else {
report.push({
group: req.group,
name: req.name,
status: ":red_circle:",
code: response.status,
lengthOrData: JSON.stringify(response.data?.data),
});
}
}
} else {
const data = JSON.stringify(response.data)?.toLocaleLowerCase();
if (
data?.includes("error") ||
data?.includes("invalid") ||
response.data.data === undefined
response.data === undefined
) {
report.push({
group: req.group,
@ -789,27 +833,6 @@ const checkMultipleRequest = async () => {
lengthOrData: response.data?.data?.length,
});
}
} else {
if (
response.data?.data !== undefined &&
response.data?.data?.length > 0
) {
report.push({
group: req.group,
name: req.name,
status: ":check:",
code: response.status,
lengthOrData: response.data?.data?.length,
});
} else {
report.push({
group: req.group,
name: req.name,
status: ":red_circle:",
code: response.status,
lengthOrData: JSON.stringify(response.data?.data),
});
}
}
}
} else {
@ -861,7 +884,9 @@ const checkMultipleRequest = async () => {
lengthOrData: "Error: " + error,
});
});
} else {
}
if (req.method === "GET") {
await axios
.get(req.url, req.data, {
headers: req.headers,
@ -885,17 +910,17 @@ const checkMultipleRequest = async () => {
});
}
if(req.method === "SSH"){
if (req.method === "SSH") {
exec(req.url, (error, stdout, stderr) => {
if (error) {
// console.error(`Error executing command: ${error.message}`);
return;
}
if (stdout !== "") {
console.log(stdout)
console.log(stdout);
} else {
console.log(stderr)
console.log(stderr);
}
});
}