Registry / http-networking / resilient-consul

resilient-consul

JSON →
library0.1.7jsnpmunverified

Middleware for resilient.js HTTP client that integrates Consul as a service discovery server. Version 0.1.7 works with Consul HTTP API v1 and resilient.js >=0.3. Supports Node.js and browsers (via Bower or script tag). Provides fault-tolerant, load-balanced HTTP requests by querying Consul's catalog or health endpoint, allowing custom server mapping and per-service datacenter/tag filters. Differentiates by adding Consul discovery to resilient.js, enabling dynamic backend selection.

npm install resilient-consul
INSTALL
IMPORT
SIG · RESILIENT-CONSUL
R
resilient-consul
http-networkingjavascriptv0.1.7
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import consul from 'resilient-consul'
const consul = require('resilient-consul')
ESM default export; CJS require works but is not idiomatic for modern JS.
consul
import { consul } from 'resilient-consul'
import consul from 'resilient-consul'
Named export also available; be consistent but default is simpler.
Resilient
import Resilient from 'resilient'
const Resilient = require('resilient')
resilient.js uses CJS; ESM imports work with bundlers.

Creates resilient HTTP client with Consul discovery using service 'web' from local Consul agent.

import Resilient from 'resilient'; import consul from 'resilient-consul'; const client = Resilient(); client.use(consul({ service: 'web', servers: ['http://localhost:8500'], datacenter: 'dc1', tag: '1.0', onlyHealthy: true, mapServers: (list) => list.map(svc => svc.ServiceAddress + '/v1') })); client.get('/api/health', (err, res) => { if (err) console.error('Error:', err); else console.log('Response:', res); });
Debug
Known issues
deprecatedresilient.js is no longer actively maintained; consider alternatives.
fix
Migrate to another HTTP client with Consul support (e.g., axios + consul library).
affects: >=0.1.0
gotchaIn browser, Consul CORS must be enabled; otherwise requests fail silently.
fix
Add 'Access-Control-Allow-Origin': '*' to Consul config http_api_response_headers.
affects: >=0.1.0
gotchaThe 'servers' option requires full URLs including protocol and port.
fix
Use 'http://consul-host:8500' not 'consul-host'.
affects: >=0.1.0
gotchaIf 'onlyHealthy' is true, health endpoint may return different data structure than catalog.
fix
Ensure mapServers handles health check response structure (array of objects with Service key).
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: consul is not a function
Default import used when package exports object with consul property.
fix
Use `import consul from 'resilient-consul'` or `const consul = require('resilient-consul')`.
Error: Cannot find module 'resilient'
Missing peer dependency resilient.js.
fix
Install resilient: `npm install resilient`.
ReferenceError: Resilient is not defined
Resilient constructor not imported correctly.
fix
Import Resilient: `import Resilient from 'resilient'` or `const Resilient = require('resilient')`.
Upgrade
Version history
0.1.7latest on npm
Audit
Dependencies
resilientrequiredPeer dependency; middleware is designed for resilient.js HTTP client
Agent activity
7 hits · last 30 days
node
6
Resources
resilient-consul — npm install resilient-consul · libregistry