node-consul-service 1.0.3 → 1.0.4

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
@@ -13,10 +13,26 @@ var require$$4$1 = require('assert');
13
13
  var zlib = require('zlib');
14
14
  var events = require('events');
15
15
 
16
+ const { CONSUL_HOST, CONSUL_PORT, CONSUL_SECURE } = process.env;
17
+ if (!CONSUL_HOST) {
18
+ throw new Error("Missing environment variable: CONSUL_HOST");
19
+ }
20
+ if (!CONSUL_PORT) {
21
+ throw new Error("Missing environment variable: CONSUL_PORT");
22
+ }
16
23
  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",
24
+ host: CONSUL_HOST,
25
+ port: Number(CONSUL_PORT),
26
+ secure: CONSUL_SECURE === "true",
27
+ });
28
+ // اختبار الاتصال
29
+ client.agent.self((err) => {
30
+ if (err) {
31
+ console.error("❌ Failed to connect to Consul:", err.message);
32
+ }
33
+ else {
34
+ console.log("✅ Connected to Consul successfully");
35
+ }
20
36
  });
21
37
 
22
38
  const registeredServices = new Set();
package/dist/index.esm.js CHANGED
@@ -11,10 +11,26 @@ import require$$4$1 from 'assert';
11
11
  import zlib from 'zlib';
12
12
  import { EventEmitter } from 'events';
13
13
 
14
+ const { CONSUL_HOST, CONSUL_PORT, CONSUL_SECURE } = process.env;
15
+ if (!CONSUL_HOST) {
16
+ throw new Error("Missing environment variable: CONSUL_HOST");
17
+ }
18
+ if (!CONSUL_PORT) {
19
+ throw new Error("Missing environment variable: CONSUL_PORT");
20
+ }
14
21
  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",
22
+ host: CONSUL_HOST,
23
+ port: Number(CONSUL_PORT),
24
+ secure: CONSUL_SECURE === "true",
25
+ });
26
+ // اختبار الاتصال
27
+ client.agent.self((err) => {
28
+ if (err) {
29
+ console.error("❌ Failed to connect to Consul:", err.message);
30
+ }
31
+ else {
32
+ console.log("✅ Connected to Consul successfully");
33
+ }
18
34
  });
19
35
 
20
36
  const registeredServices = new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-consul-service",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",