2.0.20 • Published 8 years ago

eq8 v2.0.20

Weekly downloads
5
License
Apache-2.0
Repository
github
Last release
8 years ago

EQuateJS (eq8js)

npm node David Travis codecov

Contents

Installation

npm install --save eq8

Example

var api = require('eq8')({jwt: {secret: 'secret'}});

var state = {};

api.register({
	actions: [
		{
			name: 'Change State',
			pattern: {
				cmd: 'update'
			},
			handler: function(ctxt, args) {
				state[args.id] = args.value;
			}
		}
	],
	views: [
		{
				name: 'View State',
				pattern: {
					uri: '/state/:id'
				},
				handler: function(ctxt, args, done) {
					done(null, state[args.id]);
				}
		}
	]
});

// Listen on port 8080
api.listen(8080);

The example above registers an Action that can be triggered via a WebSocket connection - as shown below - to modify the state object.

var WebSocket = require('ws');
var ws = new WebSocket('http://localhost:8080');

ws.on('open', function() {
	ws.send(JSON.stringify({
		cmd: 'update',
		id:'1',
		value: 'foo'
	}));
});

The state for any specific id was also made available via a web interface at http://localhost:8080/state/:id by registering another concept called a View.

$ curl http://localhost:8080/state/1
foo

More Info

This package extends the eq8-api and eq8-core packages with more details and examples available at https://eq8.js.org

2.0.20

8 years ago

2.0.19

8 years ago

2.0.18

8 years ago

2.0.17

8 years ago

2.0.16

8 years ago

2.0.15

8 years ago

2.0.14

8 years ago

2.0.13

8 years ago

2.0.12

8 years ago

2.0.11

8 years ago

2.0.10

8 years ago

2.0.9

8 years ago

2.0.8

8 years ago

2.0.7

8 years ago

2.0.6

9 years ago

2.0.5

9 years ago

2.0.4

9 years ago

2.0.3

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.2.0-rc3

9 years ago

0.2.0-rc2

9 years ago

0.2.0-rc1

9 years ago

0.1.0

9 years ago