Skip to content
Realtime Message Bus for the Web. Javascript Implementation
Branch: master
Clone or download
Latest commit 074a17d Aug 9, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bench add sorting bench Dec 8, 2016
bin format with standard (js) Jan 18, 2016
build bump rev 1.0.6 Jan 18, 2016
doc Support Websocket options (#293) Feb 17, 2017
examples improve balls example Mar 21, 2017
lib Ws dos fix (#321) Aug 9, 2018
test Added additional return type tests (#319) May 4, 2018
.codeclimate.yml add codeclimate config with eslint rules for standard js Oct 5, 2016
.doclets.yml add package json to doclets file Dec 30, 2015
.eslintrc
.gitignore add chat example Jun 15, 2015
.jshintrc add jshint resource Feb 17, 2015
.travis.yml Node 8 fix (#315) Sep 26, 2017
LICENSE use github template Apr 9, 2015
Makefile use uglify-js instead of uglify Jun 1, 2015
README.md JavaScript (#317) Aug 7, 2018
beautify.sh ignore all node_modules paths Apr 15, 2015
bower.json bump rev 1.0.2 Sep 13, 2015
jet-todo.png replace todo-app iframe with image link May 6, 2015
package-lock.json
package.json 1.5.6 Aug 9, 2018

README.md

About

Join the chat at https://gitter.im/lipp/node-jet npm version Build Status Code Climate Coverage Status js-standard-style deps

This is Jet for JavaScript. Jet is the hybrid of an In-Memory Database and a Realtime Push-Framework. Node and Browsers are supported (using Browserify).

Synopsis

Start a Daemon:

$ jetd.js

Provide Content:

var jet = require('node-jet');

// connect to daemon
var peer = new jet.Peer({
  url: 'ws://localhost:11123' 
});

// provide methods/factories/services/actions/etc
var greet = new jet.Method('greet');
greet.on('call', function(who) {
  console.log('Hello', who);
});

peer.add(greet);

// provide documents/realtime-status/configuration/etc
var jim = new jet.State('persons/#123', getPerson('#123'));
jim.on('set', function(changedPerson) {
  setPerson('#123', changedPerson);
  // changes are propageted automatically
});

peer.add(jim);

// provide read-only stuff
var nowState = new jet.State('time/now', new Date().getTime());

peer.add(nowState);

// change async
setInterval(function() {
  nowState.value(new Date().getTime());
}, 100);

Consume Content:

// fetch/query content
var youngestPersons = new jet.Fetcher()
  .path('startsWith', 'persons/')
  .sortByKey('age', 'number')
  .ascending()
  .range(1, 20)
  .on('data', function(persons) {
    console.log(persons);
  });

peer.fetch(youngestPersons);

// call methods
peer.call('greet', ['Steve']).then(function(response) {
  console.log(response);
});

// set states
peer.set('person/#123', {name: 'Jose', age: 33});

Tutorial

Read the Todo-App Tutorial (Vanilla JS client) or the React + Redux Variant for building this simple collaborative realtime app:

Jet Todo-App

Install

NPM

$ npm install node-jet

script tag

<script src="https://rawgit.com/lipp/node-jet/master/build/jet.js"></script>

Stand-Alone Daemon

The package provides a stand-alone Jet Daemon which listens on ports 11122 (trivial protocol) and 11123 (WebSockets) per default.

Start it like this (globally):

 $ jetd.js

Or - if installed locally:

 $ node_modules/.bin/jetd.js

Integrated Daemon

If you want the Jet Daemon to listen for WebSockets on the same port as your existing (node.js) HTTP server, use the daemon.listen({server:httpServer}) method like this:

var httpServer = http.createServer(function(req, res) {
  // serve your stuff
});
httpServer.listen(80);

var daemon = new jet.Daemon();
daemon.listen({
  server: httpServer
});

Radar

Open Radar on jetbus.io, which allows you to see/observe Your Jet States and Methods. Your local Jet Daemon's default WebSocket address is ws://localhost:11123.

Doc

For further info and documentation refer to the Jet Homepage.

Todo-App

There is also the canonical ToDo-App available:

You can’t perform that action at this time.