Socket
Socket
Sign inDemoInstall

strong-mesh-client

Package Overview
Dependencies
694
Maintainers
22
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    strong-mesh-client

strong-mesh-client


Version published
Maintainers
22
Install size
70.5 MB
Created

Readme

Source

strong-mesh-client

Background

This module provides a node.js and browser client that interacts with a set of strong-pm APIs.

Usage

Node.js

Below is an example setting up the mesh client for use in node.js.

var mesh = MeshClient.create('/path/to/config/file.json', {
  interval: 2000
});

mesh.ManagerHost.create({host: 'foo.com', port: 3000});

Browser + Proxy

First mount the proxy as an express middleware / route handler.

// app => an express / loopback app
var meshProxy = require('strong-mesh-client/proxy/server')('/path/to/config/file.json', {
  interval: 2000
});

app.use('/path/to/proxy', meshProxy.middleware(app));

Add the client script.

<script src="/path/to/proxy/client.js"></script>

Interact with mesh from the browser via the proxy.

var mesh = require('strong-mesh-client')('http://localhost:3000');;

// get notifications when hosts change
mesh.notifications.on('host changed', function() {
  mesh.ManagerHost.find(function(err, hosts) {
    $scope.hosts = hosts;
    $scope.$apply();
  });
});

// adding a host to the manager (that is a PM)
mesh.ManagerHost.create({
  host: '...',
  port: ...
}, function(err, inst) {
  // host added
});

// delete from the config
ManagerHost.deleteById('...', cb);

// perform an action on a specific host
managerHost.action({
  cmd: 'stop'
}, cb);

Models

ManagerHost

{
  host: 'foo.com',
  port: 3000,
  error: {message: '...', status: 500},
  errorType: 'connection', // correspond to the error property
  app: {
    name: 'appname',
    version: '1.2.3',
    port: 4000
  }, // if null, app is not running
  actions: [
    'start',
    'edit', // always included
    'delete' // always included
  ], // list of available actions depending on the state of the host
  processes: {
    targetCount: 7,
    pids: [{
      id: '...',
      pid: 123
    }]
  },
  credentials: {
    username: '...',
    password: '...'
  }
}

LoadBalancer

{
  host: 'foo.com',
  port: 3000,
  credentials: {
    username: '...',
    password: '...'
  },
  error: {status: 500, message: '...'}
}

FAQs

Last updated on 07 Mar 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc