node-consul-service 1.0.12 → 1.0.14
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/consul/ registry.d.ts +2 -0
- package/dist/consul/client.d.ts +3 -0
- package/dist/consul/discovery.d.ts +5 -0
- package/dist/consul/httpCaller.d.ts +10 -0
- package/dist/consul/registry.d.ts +18 -0
- package/dist/consul/types.d.ts +6 -0
- package/dist/index.cjs.js +2 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +2 -1
- package/package.json +2 -1
- package/ .gitignore +0 -30
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ServiceInstance } from './types';
|
|
2
|
+
export declare function listServices(): Promise<any[]>;
|
|
3
|
+
export declare function getServiceInstances(serviceName: string): Promise<ServiceInstance[]>;
|
|
4
|
+
export declare function getRandomServiceInstance(serviceName: string): Promise<ServiceInstance>;
|
|
5
|
+
export declare function getServiceUrl(serviceName: string): Promise<string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AxiosRequestHeaders, Method } from 'axios';
|
|
2
|
+
interface CallServiceOptions {
|
|
3
|
+
method?: Method;
|
|
4
|
+
path?: string;
|
|
5
|
+
data?: any;
|
|
6
|
+
headers?: AxiosRequestHeaders;
|
|
7
|
+
params?: Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
export declare function callService(serviceName: string, options?: CallServiceOptions): Promise<any>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type RegisterOptions = {
|
|
2
|
+
name: string;
|
|
3
|
+
id: string;
|
|
4
|
+
port: number;
|
|
5
|
+
address?: string;
|
|
6
|
+
check?: {
|
|
7
|
+
name?: string;
|
|
8
|
+
http?: string;
|
|
9
|
+
interval?: string;
|
|
10
|
+
timeout?: string;
|
|
11
|
+
deregistercriticalserviceafter?: string;
|
|
12
|
+
} | false;
|
|
13
|
+
tags?: string[];
|
|
14
|
+
meta?: Record<string, string>;
|
|
15
|
+
};
|
|
16
|
+
export declare function registerService(options: RegisterOptions): Promise<void>;
|
|
17
|
+
export declare function deregisterService(id: string): Promise<void>;
|
|
18
|
+
export {};
|
package/dist/index.cjs.js
CHANGED
|
@@ -19022,7 +19022,8 @@ const {
|
|
|
19022
19022
|
|
|
19023
19023
|
async function callService(serviceName, options = {}) {
|
|
19024
19024
|
const { method = 'GET', path = '/hello', data, headers, params, } = options;
|
|
19025
|
-
const
|
|
19025
|
+
const instance = await getRandomServiceInstance(serviceName);
|
|
19026
|
+
const url = `http://${instance.ServiceAddress}:${instance.ServicePort}${path}`;
|
|
19026
19027
|
const response = await axios.request({
|
|
19027
19028
|
url,
|
|
19028
19029
|
method,
|
package/dist/index.d.ts
ADDED
package/dist/index.esm.js
CHANGED
|
@@ -19020,7 +19020,8 @@ const {
|
|
|
19020
19020
|
|
|
19021
19021
|
async function callService(serviceName, options = {}) {
|
|
19022
19022
|
const { method = 'GET', path = '/hello', data, headers, params, } = options;
|
|
19023
|
-
const
|
|
19023
|
+
const instance = await getRandomServiceInstance(serviceName);
|
|
19024
|
+
const url = `http://${instance.ServiceAddress}:${instance.ServicePort}${path}`;
|
|
19024
19025
|
const response = await axios.request({
|
|
19025
19026
|
url,
|
|
19026
19027
|
method,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-consul-service",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"module": "dist/index.esm.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"axios": "^1.9.0",
|
|
26
|
+
"cache-center": "^1.0.8",
|
|
26
27
|
"consul": "^2.0.1"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
package/ .gitignore
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
node_modules
|
|
2
|
-
dist
|
|
3
|
-
*.tsbuildinfo
|
|
4
|
-
.env
|
|
5
|
-
.env.*
|
|
6
|
-
|
|
7
|
-
npm-debug.log*
|
|
8
|
-
yarn-debug.log*
|
|
9
|
-
yarn-error.log*
|
|
10
|
-
pnpm-debug.log*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.DS_Store
|
|
14
|
-
Thumbs.db
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.vscode/
|
|
18
|
-
.idea/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
coverage/
|
|
22
|
-
.nyc_output/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*.log
|
|
26
|
-
*.swp
|
|
27
|
-
*.swo
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.rollup.cache/
|