{"id":20334946,"url":"https://github.com/mdb/node-consul-kv","last_synced_at":"2025-09-23T02:32:42.998Z","repository":{"id":137137571,"uuid":"91856758","full_name":"mdb/node-consul-kv","owner":"mdb","description":"A tiny NPM package for interacting with Consul KV store","archived":false,"fork":false,"pushed_at":"2023-01-12T14:35:41.000Z","size":294,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-14T20:46:54.469Z","etag":null,"topics":["consul","consul-kv","node"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mdb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-20T01:15:34.000Z","updated_at":"2024-06-13T06:09:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae3e797e-6d2f-48ad-8d59-2e59cc0c7d0e","html_url":"https://github.com/mdb/node-consul-kv","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdb%2Fnode-consul-kv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdb%2Fnode-consul-kv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdb%2Fnode-consul-kv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdb%2Fnode-consul-kv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdb","download_url":"https://codeload.github.com/mdb/node-consul-kv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233920906,"owners_count":18751142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["consul","consul-kv","node"],"created_at":"2024-11-14T20:38:41.680Z","updated_at":"2025-09-23T02:32:37.937Z","avatar_url":"https://github.com/mdb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![cicd](https://github.com/mdb/node-consul-kv/actions/workflows/cicd.yaml/badge.svg)](https://github.com/mdb/node-consul-kv/actions/workflows/cicd.yaml)\n\n# consul-kv\n\nA tiny NPM package providing a minimal [Consul KV store](https://www.consul.io/api/kv.html) client.\n\n## Using consul-kv\n\n### Instantiating:\n\n```javascript\nconst Consul = require('consul-kv');\n\nconst consul = new Consul({\n  host: 'my-consul.com', // required\n  token: 'my-acl-token', // optional\n  tlsCert: '\u003cyour-cert\u003e', // optional\n  tlsKey: '\u003cyour-cert-key\u003e', // optional\n  ca: '\u003cyour-ca-cert\u003e', // optional\n  port: '8500', // optional; defaults to '8500'\n  protocol: 'https', // optional; defaults to 'https'\n});\n```\n\n### Usage\n\nCreate or update a key:\n\n```javascript\nconst resp = await consul.set('my/key', 'my-key-value');\n```\n\nRead a key:\n\n```javascript\nconst result = await consul.get('my/key');\n\nconsole.log(result.value); // the key's value; undefined if it doesn't exist\nconsole.log(result.responseStatus); // the HTTP status code of the Consul response\nconsole.log(result.responseBody); // the HTTP body of the Consul response\n```\n\nRead a the full subtree below a key (this adds a `?recurse` query to the request, per [Consul documentation](https://www.consul.io/api/kv.html)):\n\n```javascript\nconst result = await consul.get('my/key', { recurse: true });\n\nconsole.log(result); // the entire 'my/key' subtree\nconsole.log(result.responseStatus); // the HTTP status code of the Consul response\nconsole.log(result.responseBody); // the HTTP body of the Consul response\n```\n\nDelete a key:\n\n```javascript\nconst resp = await consul.delete('my/key');\n```\n\nBonus: issue your own requests \u0026 get the raw response:\n\n```javascript\nconst resp = await consul.request({\n  key: 'my/key',\n  body: 'my-value-or-optional-request-body',\n  method: 'put'\n});\n```\n\n## Development\n\nInstall dependencies \u0026 run unit tests:\n\n```\nnpm install\nnpm test\n```\n\nRun end-to-end tests against a local Consul using [docker-compose](https://docs.docker.com/compose/):\n\n```\ndocker-compose up --detach\nnpm run test:e2e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdb%2Fnode-consul-kv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdb%2Fnode-consul-kv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdb%2Fnode-consul-kv/lists"}