node-consul-service 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -90,6 +90,10 @@ async function getRandomServiceInstance(serviceName) {
90
90
  const randomIndex = Math.floor(Math.random() * instances.length);
91
91
  return instances[randomIndex];
92
92
  }
93
+ async function getServiceUrl(serviceName) {
94
+ const instance = await getRandomServiceInstance(serviceName);
95
+ return `http://${instance.ServiceAddress}:${instance.ServicePort}`;
96
+ }
93
97
 
94
98
  function bind(fn, thisArg) {
95
99
  return function wrap() {
@@ -19018,8 +19022,7 @@ const {
19018
19022
 
19019
19023
  async function callService(serviceName, options = {}) {
19020
19024
  const { method = 'GET', path = '/hello', data, headers, params, } = options;
19021
- const instance = await getRandomServiceInstance(serviceName);
19022
- const url = `http://${instance.ServiceAddress}:${instance.ServicePort}${path}`;
19025
+ const url = await getServiceUrl(serviceName);
19023
19026
  const response = await axios.request({
19024
19027
  url,
19025
19028
  method,
@@ -19034,6 +19037,7 @@ exports.callService = callService;
19034
19037
  exports.deregisterService = deregisterService;
19035
19038
  exports.getRandomServiceInstance = getRandomServiceInstance;
19036
19039
  exports.getServiceInstances = getServiceInstances;
19040
+ exports.getServiceUrl = getServiceUrl;
19037
19041
  exports.listServices = listServices;
19038
19042
  exports.registerService = registerService;
19039
19043
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.esm.js CHANGED
@@ -88,6 +88,10 @@ async function getRandomServiceInstance(serviceName) {
88
88
  const randomIndex = Math.floor(Math.random() * instances.length);
89
89
  return instances[randomIndex];
90
90
  }
91
+ async function getServiceUrl(serviceName) {
92
+ const instance = await getRandomServiceInstance(serviceName);
93
+ return `http://${instance.ServiceAddress}:${instance.ServicePort}`;
94
+ }
91
95
 
92
96
  function bind(fn, thisArg) {
93
97
  return function wrap() {
@@ -19016,8 +19020,7 @@ const {
19016
19020
 
19017
19021
  async function callService(serviceName, options = {}) {
19018
19022
  const { method = 'GET', path = '/hello', data, headers, params, } = options;
19019
- const instance = await getRandomServiceInstance(serviceName);
19020
- const url = `http://${instance.ServiceAddress}:${instance.ServicePort}${path}`;
19023
+ const url = await getServiceUrl(serviceName);
19021
19024
  const response = await axios.request({
19022
19025
  url,
19023
19026
  method,
@@ -19028,5 +19031,5 @@ async function callService(serviceName, options = {}) {
19028
19031
  return response.data;
19029
19032
  }
19030
19033
 
19031
- export { callService, deregisterService, getRandomServiceInstance, getServiceInstances, listServices, registerService };
19034
+ export { callService, deregisterService, getRandomServiceInstance, getServiceInstances, getServiceUrl, listServices, registerService };
19032
19035
  //# sourceMappingURL=index.esm.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-consul-service",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",