1.5.0 • Published 10 years ago

nexus-uplink-simple-server v1.5.0

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

Nexus Uplink Server (Simple)

Nexus Uplink is an dead-simple, lightweight protocol on top of which Flux over the Wire can be implemented.

On the client side, a Nexus Uplink Client can react to stores updates, and dispatch actions. On the server side, a Nexus Uplink Server can react to actions dispatchs, and update stores.

Briefly:

  • actions are transported via POST requests (url pathname is the action identifier, JSON-encoded body is the payload)
  • updates are transported via Websocket (or Engine.IO fallback) (as diff objects)

This package is a simple (but efficient) implementation of the Nexus Uplink server-side protocol. Also see the isomorphic client implementation of the Nexus Uplink client-side protocol.

Example

On the server:

var server = new UplinkSimpleServer({
  pid: _.guid('pid'),
  // stores, rooms and actions are url patterns whitelists
  stores: ['/ping'],
  rooms: [],
  actions: ['/ping'],
  // pass an express or express-like app
  app: express().use(cors())
});

var pingCounter = 0;

// setup action handlers
server.actions.on('/ping', function(payload) {
  // guid is a cryptosecure unique user id, automatically maintained
  var guid = payload.guid;
  var remoteDate = payload.localDate;
  var localDate = Date.now();
  console.log('client ' + guid + ' pinged.');
  console.log('latency is ' + (localDate - remoteDate) + '.');
  pingCounter++;
  server.update({ path: '/ping', value: { counter: pingCounter }});
});

On the client:

var client = new Uplink({ url: 'http://localhost' });

// subscribe to remote updates
client.subscribeTo('/ping', function(ping) {
  console.log('ping updated', ping.counter);
});

// fire-and-forget dispatch actions
setInterval(function() {
  client.dispatch('/ping', { localDate: Date.now() });
}, 1000);

Installation

npm install nexus-uplink-simple-server --save

1.5.0

10 years ago

1.4.0

10 years ago

1.3.1

10 years ago

1.3.0

10 years ago

1.2.5

10 years ago

1.2.4

10 years ago

1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.14.17

10 years ago

0.14.16

10 years ago

0.14.15

10 years ago

0.14.14

10 years ago

0.14.13

10 years ago

0.14.12

10 years ago

0.14.11

10 years ago

0.14.10

10 years ago

0.14.9

10 years ago

0.14.8

10 years ago

0.14.7

10 years ago

0.14.6

10 years ago

0.14.5

10 years ago

0.14.4

10 years ago

0.14.3

10 years ago

0.14.2

10 years ago

0.14.1

10 years ago

0.14.0

10 years ago

0.13.3

10 years ago

0.13.2

10 years ago

0.13.1

10 years ago

0.13.0

10 years ago

0.12.20

10 years ago

0.12.19

10 years ago

0.12.18

10 years ago

0.12.17

10 years ago

0.12.16

10 years ago

0.12.15

10 years ago

0.12.14

10 years ago

0.12.13

10 years ago

0.12.12

10 years ago

0.12.11

10 years ago

0.12.10

10 years ago

0.12.9

10 years ago

0.12.8

10 years ago

0.12.7

10 years ago

0.12.6

10 years ago

0.12.5

10 years ago

0.12.4

10 years ago

0.12.3

10 years ago

0.12.2

10 years ago

0.12.1

10 years ago

0.12.0

10 years ago

0.11.6

10 years ago

0.11.5

10 years ago

0.11.4

10 years ago

0.11.3

10 years ago

0.11.2

10 years ago

0.11.1

10 years ago

0.11.0

10 years ago

0.10.2

10 years ago

0.10.1

10 years ago

0.10.0

10 years ago

0.9.3

10 years ago

0.9.2

10 years ago

0.9.1

10 years ago

0.9.0

10 years ago

0.8.0

10 years ago

0.7.5

10 years ago

0.7.4

10 years ago

0.7.3

10 years ago

0.7.2

10 years ago

0.7.1

10 years ago

0.7.0

10 years ago

0.6.4

10 years ago

0.6.3

10 years ago

0.6.2

10 years ago

0.6.1

10 years ago

0.6.0

10 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.4

10 years ago

0.3.3

10 years ago

0.3.2

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago