|
|
@ -112,26 +112,26 @@ export async function validateCondition(filters: Filter[], data: any) { |
|
|
|
return isValid; |
|
|
|
return isValid; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function handleHttpWebHook(apiMeta, apiReq, data) { |
|
|
|
export async function handleHttpWebHook(apiMeta, user, data) { |
|
|
|
// try {
|
|
|
|
// try {
|
|
|
|
const req = axiosRequestMake(apiMeta, apiReq, data); |
|
|
|
const req = axiosRequestMake(apiMeta, user, data); |
|
|
|
await require('axios')(req); |
|
|
|
await require('axios')(req); |
|
|
|
// } catch (e) {
|
|
|
|
// } catch (e) {
|
|
|
|
// console.log(e);
|
|
|
|
// console.log(e);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function axiosRequestMake(_apiMeta, apiReq, data) { |
|
|
|
export function axiosRequestMake(_apiMeta, user, data) { |
|
|
|
const apiMeta = { ..._apiMeta }; |
|
|
|
const apiMeta = { ..._apiMeta }; |
|
|
|
if (apiMeta.body) { |
|
|
|
if (apiMeta.body) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
apiMeta.body = JSON.parse(apiMeta.body, (_key, value) => { |
|
|
|
apiMeta.body = JSON.parse(apiMeta.body, (_key, value) => { |
|
|
|
return typeof value === 'string' |
|
|
|
return typeof value === 'string' |
|
|
|
? parseBody(value, apiReq, data, apiMeta) |
|
|
|
? parseBody(value, user, data, apiMeta) |
|
|
|
: value; |
|
|
|
: value; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
apiMeta.body = parseBody(apiMeta.body, apiReq, data, apiMeta); |
|
|
|
apiMeta.body = parseBody(apiMeta.body, user, data, apiMeta); |
|
|
|
console.log(e); |
|
|
|
console.log(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -139,11 +139,11 @@ export function axiosRequestMake(_apiMeta, apiReq, data) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
apiMeta.auth = JSON.parse(apiMeta.auth, (_key, value) => { |
|
|
|
apiMeta.auth = JSON.parse(apiMeta.auth, (_key, value) => { |
|
|
|
return typeof value === 'string' |
|
|
|
return typeof value === 'string' |
|
|
|
? parseBody(value, apiReq, data, apiMeta) |
|
|
|
? parseBody(value, user, data, apiMeta) |
|
|
|
: value; |
|
|
|
: value; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
apiMeta.auth = parseBody(apiMeta.auth, apiReq, data, apiMeta); |
|
|
|
apiMeta.auth = parseBody(apiMeta.auth, user, data, apiMeta); |
|
|
|
console.log(e); |
|
|
|
console.log(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -152,17 +152,12 @@ export function axiosRequestMake(_apiMeta, apiReq, data) { |
|
|
|
params: apiMeta.parameters |
|
|
|
params: apiMeta.parameters |
|
|
|
? apiMeta.parameters.reduce((paramsObj, param) => { |
|
|
|
? apiMeta.parameters.reduce((paramsObj, param) => { |
|
|
|
if (param.name && param.enabled) { |
|
|
|
if (param.name && param.enabled) { |
|
|
|
paramsObj[param.name] = parseBody( |
|
|
|
paramsObj[param.name] = parseBody(param.value, user, data, apiMeta); |
|
|
|
param.value, |
|
|
|
|
|
|
|
apiReq, |
|
|
|
|
|
|
|
data, |
|
|
|
|
|
|
|
apiMeta |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return paramsObj; |
|
|
|
return paramsObj; |
|
|
|
}, {}) |
|
|
|
}, {}) |
|
|
|
: {}, |
|
|
|
: {}, |
|
|
|
url: parseBody(apiMeta.path, apiReq, data, apiMeta), |
|
|
|
url: parseBody(apiMeta.path, user, data, apiMeta), |
|
|
|
method: apiMeta.method, |
|
|
|
method: apiMeta.method, |
|
|
|
data: apiMeta.body, |
|
|
|
data: apiMeta.body, |
|
|
|
headers: apiMeta.headers |
|
|
|
headers: apiMeta.headers |
|
|
@ -170,7 +165,7 @@ export function axiosRequestMake(_apiMeta, apiReq, data) { |
|
|
|
if (header.name && header.enabled) { |
|
|
|
if (header.name && header.enabled) { |
|
|
|
headersObj[header.name] = parseBody( |
|
|
|
headersObj[header.name] = parseBody( |
|
|
|
header.value, |
|
|
|
header.value, |
|
|
|
apiReq, |
|
|
|
user, |
|
|
|
data, |
|
|
|
data, |
|
|
|
apiMeta |
|
|
|
apiMeta |
|
|
|
); |
|
|
|
); |
|
|
|