npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

msh

v0.2.4

Published

Node Microservices Shell

Downloads

107

Readme

= NodeMSH: A NodeJS implementation of Micro Service Shell

In http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/[Asciidoc] format.

:toc:

== Quick Start Examples

=== GETing POSTing PUTing and PIPEing

[source,javascript]

    var msh = require('msh'); 
    
    var h = 'localhost';
    var p = mockMshServicePort;
    var url = '/some/path';

    var callback = function(actions) {
              // Great, msh finished successfully now what?
            console.log("action 0" + JSON.stringify(actions[0]));
            console.log("action 1" + JSON.stringify(actions[1]));
            console.log("action 2" + JSON.stringify(actions[2]));
            console.log("action 3" + JSON.stringify(actions[3]));
            console.log("action 4" + JSON.stringify(actions[4]));
            console.log("action 5" + JSON.stringify(actions[5]));

              assert.equal(actions[0].type, 'http'); // every action has a type
              assert.equal(actions[0].method, 'GET'); // every http type has a method
              assert.equal(actions[1].type, 'pipe'); // this means we piped data from one action to another
              assert.equal(actions[2].statusCode, 201); // get http response status codes
              assert.equal(actions[5].response.message, 'some test data'); // put payload/response data
              assert.equal(true, actions.allOk()); // all http return code > 399
              done();
      };

      var errCallback = function(status, host, data) {
        // Oh noes! An error! Do something good to restore your Karma
      };

      var testTransformer = function(data) {return '{"message": "this was transformed from:", "oldmessage": ' + data + ' }'};
      var putData = '{"data": "putData"}';

      var host = "localhost";
      var port = 8080;

      // Here's the magic... 
      // Eh? what happened to all the nested callbacks?
      msh.init(callback, errCallback)
      .get(h, p, '/path1')
      .pipe(testTransformer)
      .post(h, p, '/path2')
      .del(h, p, '/path3')
      .get(h, p, '/path4')
      .put(h, p, '/path5', putData)
      .end();

=== Using predicates to halt execution

  var msh = require('msh');
    var h = 'localhost';
        var p = mockMshServicePort;
        var url = '/some/path';
        
       var payload = {"id":"sentiment","image":"sp_platform/uber-any","env":{"GIT_REPO_URL":"https://github.com/fuzzy-logic/sentiment.git", "DNS": "sentiment.muoncore.io"}};
        
        var errCallback = function(status, host, data) {
            console.log('errCallback status=%s, host=%s data=%s', status, host, data);
             assert.ok(false);
        };
        
        var callback = function(actions) {
            console.log('msh callback...');
           // console.dir(actions);
            
            var getStatus = actions[0].statusCode;
            var postStatus = actions[2].statusCode;
            
            console.log('action0: ' + JSON.stringify(actions[0]));
            assert.equal(200, actions[0].statusCode);
            assert.equal('http', actions[0].type);
            assert.equal('GET', actions[0].method);
            assert.ok(actions[0].response);
            
            
            console.log('action1: ' + JSON.stringify(actions[1]));
            assert.equal('stopPredicate', actions[1].type);
            assert.equal(true, actions[1].response); //predicate returned false
            
            
            console.log('action2: ' + JSON.stringify(actions[2]));
            assert.equal('http', actions[2].type);
            assert.equal('POST', actions[2].method);
            assert.equal(undefined, actions[2].response);
            
            
            done();
            
        };
    
    var predicate = function(prevAction) {
        //console.log("predicate prevAction=%s", JSON.stringify(prevAction));
        return true
    };
                                  
    console.log('msh starting...');
    msh.init(callback, errCallback).get(h, p, url, payload).stop(predicate).post(h, p, url).end();

=== Using URL Templating


            var h = 'localhost';
            var p = 80;
            var url = '/some/path';
            var url2 = '/{first}/{second}/{third}';
            
            var errCallback = function(status, host, data) {
                console.log('errCallback status=%s, host=%s data=%s', status, host, data);
            };
            
            var callback = function(actions) {
                var get1Id = actions[0].response.id;
                assert.equal(url2,  actions[2].pathTemplate);
                assert.equal('/foo/bar/' + get1Id,  actions[2].path);
                done();
                
            };
        
            var processor = function (result) {
                return {    
                    first: "foo",
                    second: "bar",
                    third: result.id // result = {id: 3}
                }
            }
            msh.init(callback, errCallback).get(h, p, url).template(processor).get(h, p, url2).end();