node-consul-service 1.0.22 → 1.0.24
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/dataLink.d.ts +2 -0
- package/dist/index.cjs.js +6 -5
- package/dist/index.esm.js +6 -5
- package/package.json +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { AxiosRequestHeaders } from "axios";
|
|
1
2
|
interface LinkSchema {
|
|
2
3
|
filed: string;
|
|
3
4
|
service: string;
|
|
4
5
|
path: string;
|
|
6
|
+
headers?: AxiosRequestHeaders;
|
|
5
7
|
cacheGetter?: (ids: string[]) => Promise<(any | null)[]>;
|
|
6
8
|
}
|
|
7
9
|
export declare function dataLink(data: any[], schema: LinkSchema[]): Promise<any[]>;
|
package/dist/index.cjs.js
CHANGED
|
@@ -420,7 +420,7 @@ client.agent.self((err) => {
|
|
|
420
420
|
|
|
421
421
|
const registeredServices = new Set();
|
|
422
422
|
async function registerService(options) {
|
|
423
|
-
var _a, _b, _c, _d
|
|
423
|
+
var _a, _b, _c, _d;
|
|
424
424
|
const { name, id, port, address = 'localhost', check, tags, meta, } = options;
|
|
425
425
|
if (registeredServices.has(id)) {
|
|
426
426
|
console.log(`⚠️ Service "${id}" is already registered.`);
|
|
@@ -434,15 +434,17 @@ async function registerService(options) {
|
|
|
434
434
|
tags,
|
|
435
435
|
meta,
|
|
436
436
|
};
|
|
437
|
-
// لو check مش موجود نضيف واحد افتراضي
|
|
438
437
|
if (check !== false) {
|
|
439
|
-
|
|
438
|
+
const checkDefinition = {
|
|
440
439
|
name: (_a = check === null || check === void 0 ? void 0 : check.name) !== null && _a !== void 0 ? _a : `${name}-check`,
|
|
441
440
|
http: (_b = check === null || check === void 0 ? void 0 : check.http) !== null && _b !== void 0 ? _b : `http://${address}:${port}/health`,
|
|
442
441
|
interval: (_c = check === null || check === void 0 ? void 0 : check.interval) !== null && _c !== void 0 ? _c : '10s',
|
|
443
442
|
timeout: (_d = check === null || check === void 0 ? void 0 : check.timeout) !== null && _d !== void 0 ? _d : '5s',
|
|
444
|
-
deregistercriticalserviceafter: (_e = check === null || check === void 0 ? void 0 : check.deregistercriticalserviceafter) !== null && _e !== void 0 ? _e : '1m',
|
|
445
443
|
};
|
|
444
|
+
if (check === null || check === void 0 ? void 0 : check.deregistercriticalserviceafter) {
|
|
445
|
+
checkDefinition.deregistercriticalserviceafter = check.deregistercriticalserviceafter;
|
|
446
|
+
}
|
|
447
|
+
serviceDefinition.check = checkDefinition;
|
|
446
448
|
}
|
|
447
449
|
await client.agent.service.register(serviceDefinition);
|
|
448
450
|
registeredServices.add(id);
|
|
@@ -19419,7 +19421,6 @@ async function callService(serviceName, options = {}) {
|
|
|
19419
19421
|
};
|
|
19420
19422
|
}
|
|
19421
19423
|
catch (error) {
|
|
19422
|
-
console.log("🚀 ~ error:", error);
|
|
19423
19424
|
return {
|
|
19424
19425
|
success: false,
|
|
19425
19426
|
message: error.message,
|
package/dist/index.esm.js
CHANGED
|
@@ -418,7 +418,7 @@ client.agent.self((err) => {
|
|
|
418
418
|
|
|
419
419
|
const registeredServices = new Set();
|
|
420
420
|
async function registerService(options) {
|
|
421
|
-
var _a, _b, _c, _d
|
|
421
|
+
var _a, _b, _c, _d;
|
|
422
422
|
const { name, id, port, address = 'localhost', check, tags, meta, } = options;
|
|
423
423
|
if (registeredServices.has(id)) {
|
|
424
424
|
console.log(`⚠️ Service "${id}" is already registered.`);
|
|
@@ -432,15 +432,17 @@ async function registerService(options) {
|
|
|
432
432
|
tags,
|
|
433
433
|
meta,
|
|
434
434
|
};
|
|
435
|
-
// لو check مش موجود نضيف واحد افتراضي
|
|
436
435
|
if (check !== false) {
|
|
437
|
-
|
|
436
|
+
const checkDefinition = {
|
|
438
437
|
name: (_a = check === null || check === void 0 ? void 0 : check.name) !== null && _a !== void 0 ? _a : `${name}-check`,
|
|
439
438
|
http: (_b = check === null || check === void 0 ? void 0 : check.http) !== null && _b !== void 0 ? _b : `http://${address}:${port}/health`,
|
|
440
439
|
interval: (_c = check === null || check === void 0 ? void 0 : check.interval) !== null && _c !== void 0 ? _c : '10s',
|
|
441
440
|
timeout: (_d = check === null || check === void 0 ? void 0 : check.timeout) !== null && _d !== void 0 ? _d : '5s',
|
|
442
|
-
deregistercriticalserviceafter: (_e = check === null || check === void 0 ? void 0 : check.deregistercriticalserviceafter) !== null && _e !== void 0 ? _e : '1m',
|
|
443
441
|
};
|
|
442
|
+
if (check === null || check === void 0 ? void 0 : check.deregistercriticalserviceafter) {
|
|
443
|
+
checkDefinition.deregistercriticalserviceafter = check.deregistercriticalserviceafter;
|
|
444
|
+
}
|
|
445
|
+
serviceDefinition.check = checkDefinition;
|
|
444
446
|
}
|
|
445
447
|
await client.agent.service.register(serviceDefinition);
|
|
446
448
|
registeredServices.add(id);
|
|
@@ -19417,7 +19419,6 @@ async function callService(serviceName, options = {}) {
|
|
|
19417
19419
|
};
|
|
19418
19420
|
}
|
|
19419
19421
|
catch (error) {
|
|
19420
|
-
console.log("🚀 ~ error:", error);
|
|
19421
19422
|
return {
|
|
19422
19423
|
success: false,
|
|
19423
19424
|
message: error.message,
|