2.1.0 • Published 2 years ago
@sealsystems/service-protocol v2.1.0
node-service-protocol
Determine protocol for connecting to a service using consul for resolving local hostname if necessary.
The environment variable TLS_UNPROTECTED is used with the folowing values:
noneNo unprotected connections are used andgetProtocolalways returnshttpsworldAll connections are unprotected andgetProtocolalways returnshttploopback(default) Connections to localhost are unprotected andgetProtocolreturnshttp, external connections are protected andgetProtocolreturnhttps.
Installation
npm install @sealsystems/service-protocolUsage
const serviceProtocol = require('@sealsystems/service-protocol');
const consul = ... // get consul from somewhere
const protocol = serviceProtocol.getProtocol(consul, 'localhost');
// --> 'http'
const isLocal = serviceProtocol.isLocal(consul, 'localhost');
// --> truegetProtocol
getProtocol(consul, hostname);Returns the protocol for connection to a service on host hostname.
isLocal
isLocal(consul, hostname);Returns true if hostname is identical to the local host.