Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@logzio-node-toolbox/consul

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@logzio-node-toolbox/consul - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

17

dist/index.d.ts

@@ -14,2 +14,7 @@ interface AnyObject {

export interface KeyValueOptions {
key?: string;
value: AnyObject;
}
export interface ValidateOptions {

@@ -49,9 +54,11 @@ fail?: boolean;

}
export interface RegisterIntervalOptions {
export interface RegisterOptions {
registerData: RegisterData;
registerRetryOptions?: RegisterRetryOptions;
}
export interface RegisterIntervalOptions extends RegisterOptions {
interval: number;
onError?: VoidFunction;
}
export declare class Consul {

@@ -62,7 +69,7 @@ public constructor(consulOptions: ConsulOptions);

public get(key?: string): AnyObject;
public set(key: string, value: AnyObject): void;
public set(keyValueOptions: KeyValueOptions): void;
public keys(key?: string): AnyObject;
public merge(key: string, values: AnyObject): AnyObject;
public merge(keyValueOptions: KeyValueOptions): AnyObject;
public watch(watchOptions?: WatchOptions): void;
public register(registerData: RegisterData, registerRetryOptions?: RegisterRetryOptions): void;
public register(registerOptions: RegisterOptions): void;
public registerInterval(registerIntervalOptions: RegisterIntervalOptions): void;

@@ -69,0 +76,0 @@ public close(): void;

@@ -111,3 +111,6 @@ import retry from 'async-retry';

async set(key, value) {
async set({
key,
value
}) {
return this.consulInstance.kv.set(this.buildKey(key), JSON.stringify(value));

@@ -120,6 +123,9 @@ }

async merge(key, values) {
async merge({
key,
value
}) {
const configValues = await this.get(key);
const currentValues = configValues ? configValues.value : {};
const newValues = deepMerge(currentValues, values);
const newValues = deepMerge(currentValues, value);
await this.set(key, newValues);

@@ -150,7 +156,10 @@ return newValues;

async register(data, registerRetryOptions = {}) {
async register({
data,
retryOptions
} = {}) {
if (!data.name || !data.id) throw new Error('must provide name and id to register for consul service discovery');
if (this.registerParams.id) return;
const options = { ...this.registerRetryOptions,
...registerRetryOptions
...retryOptions
};

@@ -172,6 +181,6 @@ const list = await retry(async () => this.consulInstance.agent.service.list(), options);

onError,
registerRetryOptions
retryOptions
}) {
const options = { ...this.registerRetryOptions,
...registerRetryOptions
...retryOptions
};

@@ -178,0 +187,0 @@

{
"name": "@logzio-node-toolbox/consul",
"version": "0.0.12",
"version": "0.0.13",
"description": "Consul easy use for json configs and service discovery",

@@ -5,0 +5,0 @@ "main": "dist/index.cjs",

@@ -42,3 +42,3 @@ <p align="center">

```javascript
await consul.set('somepath/config.json', {key: "value"})
await consul.set({key: 'somepath/config.json', value: {some: "value"}})
// if have base path will set to 'some_base_url/somepath/config.json'

@@ -55,3 +55,3 @@ ```

```javascript
await consul.merge('somepath/config.json', {newKey: "newValue" })
await consul.merge({key: 'somepath/config.json', value: {toOverride: "newValue" }})
```

@@ -75,3 +75,3 @@

### register - will register to service discovery and with given params will interval to make sure service is still registered
### register - will register service to consul
receive same registerRetryOptions object as the initializer ( will merge them together)

@@ -90,3 +90,21 @@ ```javascript

data,
validateRegisteredInterval: 3000,
registerRetryOptions
})
```
### registerInterval - will create interval to validate service always register to consul
receive same registerRetryOptions object as the initializer ( will merge them together)
```javascript
interface RegisterData {
meta?: AnyObject;
checks?: AnyObject;
address?: string;
id?: string;
name?: string;
port?: number;
}
await consul.register({
data,
interval: 3000,
onError:(err) => {

@@ -99,2 +117,3 @@ console.log(err)

#### close - deregister and close all watchers

@@ -101,0 +120,0 @@ receive same registerRetryOptions object as the initializer ( will merge them together)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc