node package manager

m_jet

m_jet

Build Status

Full stack node js framework.

m_jet: a tool for prototyping websites and API's that supports re-connecting multiplexed websockets.

m_jet uses Routes, Shoe & Dataplex:

Routes

Please refer to routes documentation for its capabilities...

routes on github.

Dataplex

Data is sent via dataplex and named multiplexed websocket streams, in the browser and server. Dataplex behaves like any other stream, allowing you to pipe to and pipe from it. Check out dataplex's documentation for more usage examples.

dataplex on github.

install

npm install m_jet --save

example

var jet = require('m_jet').server();
 
jet.router.addRoute('/json/api', function (req, res) {
    jet.json(res, { a: 'demo!' });
});
 
jet.router.addRoute('/', function (req, res) {
    jet.render_html(res, 'index.html');
});
 
jet.router.addRoute('/wildcard/:id?', function (req, res, j) {
    if (j.params.id === 'summin') {
        res.end('<h1>wildcard route</h1>');
    }
});
 
jet.socket(function (plex) {
    plex.add('/demo', function () {
        var d = new Readable;
        d.push('1');
        d.push('2');
        d.push('3');
        d.push(null);
        return d;
    });
});
 
jet.start();

on the client.

var jet = require('m_jet').client();
 
jet(function (plex) {
    
    let demo = plex.open('/demo');
    
    demo.on('data', function (data) {
        console.log(data);
    });
});

client events

var jet = require('m_jet').client();
 
jet(function (plex, session) {
    
    let demo = plex.open('/demo');
    
    demo.on('data', function (data) {
        console.log(data);
    });
 
    session.on('connect', function () { console.log('connected!'); })
    session.on('disconnect', function () { console.log('client disconnected!'); })
    session.on('error', function (e) { console.log('an error has occured: ', e) })
 
    // cleanly exit this websocket session... 
 
    session.destroy()
 
});

build with browserify...

browserify ./client.js -o public/bundle.js

include in the browser...

<script src="./bundle.js"></script>

todo

  1. CORS?
  2. middlewares / plugins / extendability?

contributions

  1. All contributions / abuse / ideas welcome!