fix
All checks were successful
Build And Deploy Main / build-and-deploy (push) Successful in 33s

This commit is contained in:
2026-03-16 15:34:16 -04:00
parent 0b65071c40
commit 397043807b

View File

@@ -8,7 +8,6 @@ var bcrypt = require("bcryptjs");
const { splitSite } = require("../middlewares"); const { splitSite } = require("../middlewares");
const SYSTEM_ACCESS_PERMISSION = "System Access"; const SYSTEM_ACCESS_PERMISSION = "System Access";
const HR_EMPLOYEE_LIST_ENDPOINT = "https://ws-hr.mayosolution.com/api/integration/employees"; const HR_EMPLOYEE_LIST_ENDPOINT = "https://ws-hr.mayosolution.com/api/integration/employees";
const HR_EMPLOYEE_LIST_FALLBACK_ENDPOINT = "https://ws-hr.mayosolution.com/api/integration/employees/list";
const HR_INTEGRATION_USERNAME = "vibecodingking"; const HR_INTEGRATION_USERNAME = "vibecodingking";
const HR_INTEGRATION_PASSWORD = "oAQC483f1jxdJdoJcd0kCAd7C"; const HR_INTEGRATION_PASSWORD = "oAQC483f1jxdJdoJcd0kCAd7C";
const HR_INSECURE_HTTPS_AGENT = new https.Agent({ rejectUnauthorized: false }); const HR_INSECURE_HTTPS_AGENT = new https.Agent({ rejectUnauthorized: false });
@@ -350,7 +349,6 @@ exports.getExternalEmployeesList = async (req, res) => {
password: HR_INTEGRATION_PASSWORD password: HR_INTEGRATION_PASSWORD
} }
]; ];
const endpoints = [HR_EMPLOYEE_LIST_ENDPOINT, HR_EMPLOYEE_LIST_FALLBACK_ENDPOINT];
const normalizeEmployeesList = (raw) => { const normalizeEmployeesList = (raw) => {
if (Array.isArray(raw)) return raw; if (Array.isArray(raw)) return raw;
if (Array.isArray(raw?.data)) return raw.data; if (Array.isArray(raw?.data)) return raw.data;
@@ -362,30 +360,28 @@ exports.getExternalEmployeesList = async (req, res) => {
try { try {
let bestResponseData = null; let bestResponseData = null;
for (const endpoint of endpoints) { for (const requestBody of requestBodies) {
for (const requestBody of requestBodies) { try {
try { console.log("[HR Integration] Requesting employee list from:", HR_EMPLOYEE_LIST_ENDPOINT, "payload:", requestBody);
console.log("[HR Integration] Requesting employee list from:", endpoint, "payload:", requestBody); const response = await axios.post(HR_EMPLOYEE_LIST_ENDPOINT, requestBody, requestOptions);
const response = await axios.post(endpoint, requestBody, requestOptions); const list = normalizeEmployeesList(response?.data);
const list = normalizeEmployeesList(response?.data); console.log(
console.log( "[HR Integration] employee list response meta:",
"[HR Integration] employee list response meta:", { endpoint: HR_EMPLOYEE_LIST_ENDPOINT, count: list.length, responseType: typeof response?.data }
{ endpoint, count: list.length, responseType: typeof response?.data } );
); console.log("[HR Integration] raw employee list response:", response?.data);
console.log("[HR Integration] raw employee list response:", response?.data); bestResponseData = response?.data;
bestResponseData = response?.data; if (list.length > 0) {
if (list.length > 0) { return res.send(list);
return res.send(list);
}
} catch (attemptError) {
console.log("[HR Integration] employee list attempt failed:", {
endpoint,
payload: requestBody,
status: attemptError?.response?.status,
data: attemptError?.response?.data,
message: attemptError?.message
});
} }
} catch (attemptError) {
console.log("[HR Integration] employee list attempt failed:", {
endpoint: HR_EMPLOYEE_LIST_ENDPOINT,
payload: requestBody,
status: attemptError?.response?.status,
data: attemptError?.response?.data,
message: attemptError?.message
});
} }
} }
const emptyList = normalizeEmployeesList(bestResponseData); const emptyList = normalizeEmployeesList(bestResponseData);