Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jetstream

Package Overview
Dependencies
Maintainers
2
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jetstream

Jetstream Sync server framework to sync local and remote models

  • 0.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-54.55%
Maintainers
2
Weekly downloads
 
Created
Source

Jetstream

Build Status

Jetstream for Node is a server that brokers syncing Jetstream models over the Jetstream Sync protocol. Out of the box it has a single Websocket transport adapter with the ability to add custom transport adapters.

Features

  • Synchronize a shared set of models between many clients
  • Client and server message acknowledgement and resend capabilities
  • Transactional application of changesets
  • Synchronize and validate changesets with downstream services
  • Modular architecture
  • Comprehensive Unit Test Coverage

Communication

  • If you found a bug, fix it and submit a pull request, or open an issue.
  • If you have a feature request, implement it and submit a pull request or open an issue.
  • If you want to contribute, submit a pull request.
  • For further details see CONTRIBUTION.md.

Installation

npm install jetstream

Run demo

npm start

Tests

npm test

Documentation

See the docs directory. A good start is with docs/overview.md.

Usage

Creating models

Jetstream works with two basic concepts: All your model objects extend from the superclass ModelObject and one of your ModelObject instances will be the root for your model tree encapsulated by a Scope.

Let's model a canvas of shapes:

var createModel = require('jetstream').model;

var Shape = createModel('Shape', function() {
    this.has('x', Number);
    this.has('y', Number);
    this.has('width', Number);
    this.has('height', Number);
    this.has('type', Number);
});

var Canvas = createModel('Canvas', function() {
    this.has('name', String);
    this.has('shapes', [Shape]);
});

Supported types are String, Number, Boolean, Date, ModelObject and [ModelObject]

Creating a server

var createScope = require('jetstream').scope;
var createServer = require('jetstream');
var createWebsocketTransport = require('jetstream').transport.WebsocketTransport.configure;

// Example of connecting multiple clients to a shared scope
var canvas = new Canvas();
canvas.name = 'Shapes Demo';

var scope = createScope({name: 'Canvas'});
scope.setRoot(canvas);

// Start server with default transports
var websocketTransport = createWebsocketTransport({port: 3000});
var transports = [websocketTransport];
var server = createServer({transports: transports});
server.on('session', function(session, params, callback) {
    // Accept the session, no authentication or authorization in this example
    callback();

    session.on('fetch', function(name, params, callback) {
        // Verify fetching the scope 
        if (name !== scope.name) {
            return callback(new Error('No such scope'));
        }
        callback(null, scope);
    });
});

Protocol

Jetstream uses JSON-based messages to create sessions, fetch scopes and synchronize changes. In case you want to build your own client or server, refer to the protocol documentation.

License

Jetstream is available under the MIT license. See the LICENSE file for more info.

Keywords

FAQs

Package last updated on 04 Feb 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc