node-consul-service 1.0.46 → 1.0.48

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.
@@ -1,9 +1,8 @@
1
1
  import Consul from "consul";
2
- interface ConsulConfig {
3
- host: string;
4
- port: number;
2
+ export interface ConsulClientOptions {
3
+ host?: string;
4
+ port?: number;
5
5
  secure?: boolean;
6
6
  }
7
- export declare function initClient(config: ConsulConfig): void;
7
+ export declare function initClient({ host, port, secure, }: ConsulClientOptions): void;
8
8
  export declare function getClient(): Consul;
9
- export {};
package/dist/index.cjs.js CHANGED
@@ -15,14 +15,13 @@ var events = require('events');
15
15
 
16
16
  // src/lib/client.ts
17
17
  let consulClient = null;
18
- function initClient(config) {
19
- var _a;
18
+ function initClient({ host = "127.0.0.1", port = 8500, secure = false, }) {
19
+ console.log("🚀 ~ secure:", secure, typeof secure);
20
20
  consulClient = new Consul({
21
- host: config.host,
22
- port: config.port,
23
- secure: (_a = config.secure) !== null && _a !== void 0 ? _a : true,
21
+ host: host !== null && host !== void 0 ? host : "127.0.0.1",
22
+ port: port !== null && port !== void 0 ? port : 8500,
23
+ secure: Boolean(secure),
24
24
  });
25
- // optional test connection
26
25
  consulClient.agent.self((err) => {
27
26
  if (err) {
28
27
  console.error("❌ Failed to connect to Consul:", err.message);
package/dist/index.esm.js CHANGED
@@ -13,14 +13,13 @@ import { EventEmitter } from 'events';
13
13
 
14
14
  // src/lib/client.ts
15
15
  let consulClient = null;
16
- function initClient(config) {
17
- var _a;
16
+ function initClient({ host = "127.0.0.1", port = 8500, secure = false, }) {
17
+ console.log("🚀 ~ secure:", secure, typeof secure);
18
18
  consulClient = new Consul({
19
- host: config.host,
20
- port: config.port,
21
- secure: (_a = config.secure) !== null && _a !== void 0 ? _a : true,
19
+ host: host !== null && host !== void 0 ? host : "127.0.0.1",
20
+ port: port !== null && port !== void 0 ? port : 8500,
21
+ secure: Boolean(secure),
22
22
  });
23
- // optional test connection
24
23
  consulClient.agent.self((err) => {
25
24
  if (err) {
26
25
  console.error("❌ Failed to connect to Consul:", err.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-consul-service",
3
- "version": "1.0.46",
3
+ "version": "1.0.48",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",