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 🙏

© 2024 – Pkg Stats / Ryan Hefner

yakety

v0.1.6

Published

Bi-directional node to node messaging and request-reply.

Downloads

37

Readme

Yakety

build status NPM version node version

Bi-directional node to node messaging and request-reply.

Both the server and client can send and receive messages as well as requests-replys.

Yakety is a bit like a RESTful service, but allows the server to instigate requests to the client, plus fire-and-forget messages. Yakety will also maintain persistent connections by automatically reconnecting clients. Yakety is for back-end node to node communications, not a browser compatible solution.

Installation

npm install yakety

Examples

See examples folder.

Server example

const yakety = require('yakety');

var options = {
  protocol: 'ws',            // or 'wss' for secure.
  slowHandshake: true,      // true: can do your own authorization and handshake or close socket.
  port: 8080
};


var server = new yakety.server();

server.bind(options);

// auth clients:
server.on('authorize', function(client) {
  console.log('authorize client');

  if ( !client.headers.authorization ) {
    client.goodbye(401);
  } else if ( client.headers.authorization.password === 'password' ) {
    client.handshake();
  } else {
    client.goodbye(401);
  }

});

server.on('connected', function(client) {
  console.log('client connected');
  client.request('yakMethod', 'yakety yak?', function(err, reply) {
    if ( err ) {
      console.log('client.request reply error', err);
      return;
    }
    console.log('got reply back:', reply.toString());
    client.message('this is rock and roll.');
  });

  client.on('message', function(message, meta) {
    console.log('server got message:', message.toString());
  });

  client.on('request', function(meta, req, rep) {
    console.log('got request, method: ' + meta.method + ', req:', req.toString());
    rep('yak!');
  });

  client.on('close', function(client) {
    console.log('client close-ed');
  });

});

Client example

const yakety = require('yakety');

var options = {
  protocol: 'ws',      // or 'wss' for secure.
  hostname: '127.0.0.1',
  port: 8080,
  path: '/foo/bar/?hello=world',
  auth: 'username:password'
};

var client = new yakety.client();

client.connect(options);

client.message('hello');

client.request('yaketyyakMethod', 'yakety?', function(err, reply) {
  if ( err ) {
    console.log('client.request reply error', err);
    return;
  }
  console.log('got reply to yakety?:', reply.toString());
});

client.on('message', function(message, meta) {
  console.log('got message:', message.toString());
});

client.on('request', function(meta, req, rep) {
  console.log('got request, method: ' + meta.method + ', req:', req.toString());
  rep('Talking back!');
});

client.on('error', function(err) {
  console.log('client-app-err', err);
});

Test

npm test

Notes

Yakety is built on top of these open protocols: naked-websocket for TCP/TLS network link and SMP for message framing, with any payload codec: String, Buffer, JSON, MsgPack, etc.

License

Choose either: MIT or Apache 2.0.