New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

consul-kv

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

consul-kv

A micro library to get, set, and delete Consul K/V

latest
npmnpm
Version
0.2.2
Version published
Weekly downloads
34
161.54%
Maintainers
1
Weekly downloads
 
Created
Source

cicd

consul-kv

A tiny NPM package providing a minimal Consul KV store client.

Using consul-kv

Instantiating:

const Consul = require('consul-kv');

const consul = new Consul({
  host: 'my-consul.com', // required
  token: 'my-acl-token', // optional
  tlsCert: '<your-cert>', // optional
  tlsKey: '<your-cert-key>', // optional
  ca: '<your-ca-cert>', // optional
  port: '8500', // optional; defaults to '8500'
  protocol: 'https', // optional; defaults to 'https'
});

Usage

Create or update a key:

const resp = await consul.set('my/key', 'my-key-value');

Read a key:

const result = await consul.get('my/key');

console.log(result.value); // the key's value; undefined if it doesn't exist
console.log(result.responseStatus); // the HTTP status code of the Consul response
console.log(result.responseBody); // the HTTP body of the Consul response

Read a the full subtree below a key (this adds a ?recurse query to the request, per Consul documentation):

const result = await consul.get('my/key', { recurse: true });

console.log(result); // the entire 'my/key' subtree
console.log(result.responseStatus); // the HTTP status code of the Consul response
console.log(result.responseBody); // the HTTP body of the Consul response

Delete a key:

const resp = await consul.delete('my/key');

Bonus: issue your own requests & get the raw response:

const resp = await consul.request({
  key: 'my/key',
  body: 'my-value-or-optional-request-body',
  method: 'put'
});

Development

Install dependencies & run unit tests:

npm install
npm test

Run end-to-end tests against a local Consul using docker-compose:

docker compose up --detach
npm run test:e2e

FAQs

Package last updated on 05 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts