node-jet
TypeScript icon, indicating that this package has built-in type declarations

3.0.14 • Public • Published

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

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:

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.0.1452latest
3.0.0-beta-70beta

Version History

VersionDownloads (Last 7 Days)Published
3.0.1452
3.0.130
3.0.120
3.0.110
3.0.100
3.0.90
3.0.80
3.0.70
3.0.60
3.0.6-beta.10
3.0.6-beta1
3.0.50
3.0.40
3.0.30
3.0.20
3.0.00
3.0.0-beta-70
3.0.0-beta-60
3.0.0-beta-50
2.1.21
3.0.0-beta.40
3.0.0-beta.20
3.0.0-beta.10
3.0.0-beta.00
2.1.10
2.1.00
2.0.00
1.6.312
1.6.10
1.5.63
1.5.40
1.5.30
1.5.20
1.5.10
1.5.00
1.4.00
1.3.30
1.3.20
1.3.10
1.3.00
1.2.20
1.2.10
1.2.00
1.1.00
1.0.61
1.0.50
1.0.40
1.0.30
1.0.20
1.0.00
0.3.40
0.3.20
0.3.10
0.3.00
0.2.00
0.1.50
0.1.40
0.1.30
0.1.20
0.1.10
0.1.00
0.0.120
0.0.110
0.0.100
0.0.90
0.0.80
0.0.7-20
0.0.70
0.0.60
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i node-jet

Weekly Downloads

70

Version

3.0.14

License

MIT

Unpacked Size

110 kB

Total Files

51

Last publish

Collaborators

  • lipp
  • soenmez
  • florian-schopp