UNPKG

@daedalus/wso2

Version:

This is a set of tools to help connect and manage interactions with various WSO2 products. Please see README.MD for more details.

74 lines (70 loc) 2.05 kB
const https = require("https"); const axios = require("axios").create({ httpsAgent: new https.Agent({ rejectUnauthorized: false }), proxy: false }); const serviceResource = "bpmn/repository/process-definitions/"; /* data = { server: { url: "" }, auth: { username: "", password: "" } } */ //GET //https://<Host Name>:<Port>/bpmn/repository/process-definitions //This request retrieves all the process definitions from the server. //Note: You can use this request when you need to find a processDefinitionID or //processDefinitionKey to be sent with a request. In the response body below, //'id' is the processDefinitionId and 'key' is the processDefinitionKey. const getAll = (data, callback) => { let size = data.size ? data.size : 500; let url = data.server.url + serviceResource + '?size=' + size; let options = { auth: data.auth }; axios .get(url, options) .then(response => { callback(null, response.data); }) .catch(error => { if (error.response && error.response.data) { callback(null, { success: false, msg: error.response.data}); } else { callback(null, { success: false, msg: 'Uknown Error from Axios'}); } }); }; //GET //https://<Host Name>:<Port>/bpmn/repository/process-definitions/{processDefinitionId} //This request retrieves a specific process definition based on the specified process //definition Id. const get = (id, data, callback) => { let url = data.server.url + serviceResource + id; let options = { auth: data.auth }; axios .get(url, options) .then(response => { callback(null, response.data); }) .catch(error => { if (error.response && error.response.data) { callback(null, { success: false, msg: error.response.data}); } else { callback(null, { success: false, msg: 'Uknown Error from Axios'}); } }); }; module.exports = { getAll, get };