consul-cli-js
A node.js wrapper for the consul command line tool
Installation
Step 1: Prerequisites
The consul binary must be installed and accessible in the path e.g. Installing Consul
Step 2: Installation
npm install consul-cli-js
Then:
var consulCli = require('consul-cli-js');
var Options = consulCli.Options;
var Consul = consulCli.Consul;
Usage
With promise
var options = new Options(
'0.0.0.0:8500',
null
);
var consul = new Consul(options);
consul.command('members').then(function (data) {
console.log('data = ', data);
});
With callback:
consul.command('members', '', function (err, data) {
console.log('data = ', data);
});
Typescript
import { Consul, Options } from 'consul-cli-js';
const options = new Options(
'0.0.0.0:8500',
null
);
const consul = new Consul(options);
return consul.command('info', '', function (err, data) {
console.log('data = ', data);
});
consul.command('join', '54.86.97.135').then(function (data) {
console.log('data = ', data);
});
consul.command('info').then(function (data) {
console.log('data = ', data);
});
License
MIT