New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

seal-connect-service-cl

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seal-connect-service-cl

Connects to a service.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

seal-connect-service

CircleCI AppVeyor

Connects to a service with given host name and port number.

Installation

$ npm install seal-connect-service

Quick start

First you need to add a reference to seal-connect-service within your application.

const connectService = require('seal-connect-service');

Please note: A connection to consul must already exist before you can use the module.

To create a HTTP/HTTPS connection to an instance of a service (e.g. myService), use:

connectService({
  service: 'myService',
  path: '/job'
}, {
  name: 'hostname',
  port: 3000
}, (err, client) => {
  if (!err) {
    throw new Error('An error occurred while connecting to the service.');
  }

  client.on('response', (response) => {
    console.log(`Response status: ${response.statusCode}`);
  });

  client.write('Hello service!');
  client.end();
});

The first parameter is an options object that can contain the following properties:

propertytypedescription
servicerequired stringName of the service to access
headersoptional objectAdditional HTTP/HTTPS headers
methodoptional stringHTTP/HTTPS method, default POST
pathoptional stringURL-path to access, default /

Here is an example of a more complete options object:

const options = {
  headers: {
    'content-type': 'application/json'
  },
  method: 'POST',
  path: '/url/path',
  service: 'myService'
};

Second parameter is the host name and port number. Example:

const host = {
  name: 'hostname',
  port: 3000
};

The callback function given as the third parameter will be called when a connection to the service could be established. In this case, the err parameter is null and the req parameter contains a http.ClientRequest object for further use. Otherwise, the err parameter contains an Error object with further details about the problem.

HTTP and HTTPS

The protocol used for a connection depends on the target (local or remote) and the value of the environment variable TLS_UNPROTECTED. The TLS certificates provided by seal-tlscert will be used for HTTPS connections. It is not possible to override the chosen protocol.

Running the build

To build this module use roboter.

$ bot

FAQs

Package last updated on 14 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc