@sealsystems/service-protocol

2.1.0 • Public • Published

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:

  • none No unprotected connections are used and getProtocol always returns https
  • world All connections are unprotected and getProtocol always returns http
  • loopback (default) Connections to localhost are unprotected and getProtocol returns http, external connections are protected and getProtocol return https.

Installation

npm install @sealsystems/service-protocol

Usage

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');
// --> true

getProtocol

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @sealsystems/service-protocol

Weekly Downloads

2

Version

2.1.0

License

MIT

Unpacked Size

4.66 kB

Total Files

6

Last publish

Collaborators

  • seal-mt
  • michaelscherer-seal
  • comgit
  • gel