node-consul-service 1.0.0 → 1.0.2
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/ .gitignore +7 -15
- package/dist/index.cjs.js +14 -3
- package/dist/index.esm.js +14 -3
- package/package.json +8 -2
package/ .gitignore
CHANGED
|
@@ -1,38 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
# build output
|
|
5
|
-
dist/
|
|
6
|
-
|
|
7
|
-
# TypeScript cache
|
|
1
|
+
node_modules
|
|
2
|
+
dist
|
|
8
3
|
*.tsbuildinfo
|
|
9
|
-
|
|
10
|
-
# local env files
|
|
11
4
|
.env
|
|
12
5
|
.env.*
|
|
13
6
|
|
|
14
|
-
# logs
|
|
15
7
|
npm-debug.log*
|
|
16
8
|
yarn-debug.log*
|
|
17
9
|
yarn-error.log*
|
|
18
10
|
pnpm-debug.log*
|
|
19
11
|
|
|
20
|
-
|
|
12
|
+
|
|
21
13
|
.DS_Store
|
|
22
14
|
Thumbs.db
|
|
23
15
|
|
|
24
|
-
|
|
16
|
+
|
|
25
17
|
.vscode/
|
|
26
18
|
.idea/
|
|
27
19
|
|
|
28
|
-
|
|
20
|
+
|
|
29
21
|
coverage/
|
|
30
22
|
.nyc_output/
|
|
31
23
|
|
|
32
|
-
|
|
24
|
+
|
|
33
25
|
*.log
|
|
34
26
|
*.swp
|
|
35
27
|
*.swo
|
|
36
28
|
|
|
37
|
-
|
|
29
|
+
|
|
38
30
|
.rollup.cache/
|
package/dist/index.cjs.js
CHANGED
|
@@ -13,7 +13,11 @@ var require$$4$1 = require('assert');
|
|
|
13
13
|
var zlib = require('zlib');
|
|
14
14
|
var events = require('events');
|
|
15
15
|
|
|
16
|
-
const client = new Consul(
|
|
16
|
+
const client = new Consul({
|
|
17
|
+
host: process.env.CONSUL_HOST || "localhost",
|
|
18
|
+
port: Number(process.env.CONSUL_PORT || 8500),
|
|
19
|
+
secure: process.env.CONSUL_SECURE === "true",
|
|
20
|
+
});
|
|
17
21
|
|
|
18
22
|
const registeredServices = new Set();
|
|
19
23
|
async function registerService(name, id, port, address = 'localhost') {
|
|
@@ -18988,10 +18992,17 @@ const {
|
|
|
18988
18992
|
mergeConfig
|
|
18989
18993
|
} = axios;
|
|
18990
18994
|
|
|
18991
|
-
async function callService(serviceName,
|
|
18995
|
+
async function callService(serviceName, options = {}) {
|
|
18996
|
+
const { method = 'GET', path = '/hello', data, headers, params, } = options;
|
|
18992
18997
|
const instance = await getRandomServiceInstance(serviceName);
|
|
18993
18998
|
const url = `http://${instance.ServiceAddress}:${instance.ServicePort}${path}`;
|
|
18994
|
-
const response = await axios.
|
|
18999
|
+
const response = await axios.request({
|
|
19000
|
+
url,
|
|
19001
|
+
method,
|
|
19002
|
+
data,
|
|
19003
|
+
headers,
|
|
19004
|
+
params,
|
|
19005
|
+
});
|
|
18995
19006
|
return response.data;
|
|
18996
19007
|
}
|
|
18997
19008
|
|
package/dist/index.esm.js
CHANGED
|
@@ -11,7 +11,11 @@ import require$$4$1 from 'assert';
|
|
|
11
11
|
import zlib from 'zlib';
|
|
12
12
|
import { EventEmitter } from 'events';
|
|
13
13
|
|
|
14
|
-
const client = new Consul(
|
|
14
|
+
const client = new Consul({
|
|
15
|
+
host: process.env.CONSUL_HOST || "localhost",
|
|
16
|
+
port: Number(process.env.CONSUL_PORT || 8500),
|
|
17
|
+
secure: process.env.CONSUL_SECURE === "true",
|
|
18
|
+
});
|
|
15
19
|
|
|
16
20
|
const registeredServices = new Set();
|
|
17
21
|
async function registerService(name, id, port, address = 'localhost') {
|
|
@@ -18986,10 +18990,17 @@ const {
|
|
|
18986
18990
|
mergeConfig
|
|
18987
18991
|
} = axios;
|
|
18988
18992
|
|
|
18989
|
-
async function callService(serviceName,
|
|
18993
|
+
async function callService(serviceName, options = {}) {
|
|
18994
|
+
const { method = 'GET', path = '/hello', data, headers, params, } = options;
|
|
18990
18995
|
const instance = await getRandomServiceInstance(serviceName);
|
|
18991
18996
|
const url = `http://${instance.ServiceAddress}:${instance.ServicePort}${path}`;
|
|
18992
|
-
const response = await axios.
|
|
18997
|
+
const response = await axios.request({
|
|
18998
|
+
url,
|
|
18999
|
+
method,
|
|
19000
|
+
data,
|
|
19001
|
+
headers,
|
|
19002
|
+
params,
|
|
19003
|
+
});
|
|
18993
19004
|
return response.data;
|
|
18994
19005
|
}
|
|
18995
19006
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-consul-service",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"module": "dist/index.esm.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
"build": "rollup -c",
|
|
9
9
|
"dev": "ts-node src/index.ts"
|
|
10
10
|
},
|
|
11
|
-
"keywords": [
|
|
11
|
+
"keywords": [
|
|
12
|
+
"consul",
|
|
13
|
+
"microservices",
|
|
14
|
+
"nodejs",
|
|
15
|
+
"service-discovery"
|
|
16
|
+
],
|
|
12
17
|
"author": "abdalstar",
|
|
13
18
|
"license": "ISC",
|
|
14
19
|
"description": "",
|
|
@@ -25,6 +30,7 @@
|
|
|
25
30
|
"@rollup/plugin-json": "^6.1.0",
|
|
26
31
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
27
32
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
33
|
+
"@types/node": "^22.15.15",
|
|
28
34
|
"rollup": "^4.40.2",
|
|
29
35
|
"tslib": "^2.8.1",
|
|
30
36
|
"typescript": "^5.8.3"
|