Go to file
2017-01-29 10:57:59 -08:00
.idea Removing .idea/misc.xml file 2016-12-06 18:36:49 -08:00
samples 18 - Changing all hostname to host, fixing some async issues in tests 2017-01-28 18:04:58 -08:00
src 19: Implement cluster discovery using dns 2017-01-29 10:57:59 -08:00
test 19: Implement cluster discovery using dns 2017-01-29 10:57:59 -08:00
.gitignore 18 - Changing all hostname to host, fixing some async issues in tests 2017-01-28 18:04:58 -08:00
index.d.ts 18 - Changing all hostname to host, fixing some async issues in tests 2017-01-28 18:04:58 -08:00
index.js Adding tests 2016-10-14 22:53:23 -07:00
LICENSE Initial commit 2016-03-09 11:52:01 -08:00
package.json Updated README, bumped to version 0.0.24 2017-01-28 18:28:36 -08:00
README.md Updated README, bumped to version 0.0.24 2017-01-28 18:28:36 -08:00
Vagrantfile 18 - Changing all hostname to host, fixing some async issues in tests 2017-01-28 18:04:58 -08:00
webpack.config.js using webpack to generate a distribution version in ./lib/dist.js 2016-03-09 17:03:26 -08:00

eventstore-node

A port of the EventStore .Net ClientAPI to Node.js

Status

Missing features:

  • Ssl connection
  • Cluster discovery via dns (works using gossip seeds)
  • Set system settings

Areas to improve

  • Errors
    • Use codes or types to differentiate between errors
  • Performance
    • Performance hasn't been tested yet
  • Tests
    • Can always do with more tests

Getting started

Install using npm install eventstore-node

Dependencies

API Documentation

Offline

The offline documentation can be found in the module folder ./node_modules/eventstore-node/docs.

Online

The online documentation can be found at https://dev.nicdex.com/eventstore-node/docs/

Install & run an Eventstore on localhost

See http://docs.geteventstore.com/introduction/3.9.0/ .

Example: Storing an event

Save to app.js:

var esClient = require('eventstore-node');
var uuid = require('uuid');

var streamName = "testStream";
var esConnection = esClient.createConnection({}, "tcp://localhost:1113");
esConnection.connect();
esConnection.once('connected', function (tcpEndPoint) {
    console.log('Connected to eventstore at ' + tcpEndPoint.host + ":" + tcpEndPoint.port);
});

var eventId = uuid.v4();
var eventData = {
    a : Math.random(), 
    b: uuid.v4()
};
var event = esClient.createJsonEventData(eventId, eventData, null, 'testEvent');
console.log("Appending...");
esConnection.appendToStream(streamName, esClient.expectedVersion.any, event)
    .then(function(result) {
        console.log("Stored event:", eventId);
        console.log("Look for it at: http://localhost:2113/web/index.html#/streams/testStream");
        esConnection.close();
    })
    .catch(function(err) {
        console.log(err);
    });

Run:

npm install uuid
npm install eventstore-node
node app.js

Example: Subscribing to events

cd samples

To subscribe to all events from now on (includes example of a filter which ignores events which we aren't interested in):

node subscribe-all-events.js

To catch up on all events ever and subscribe to all new ones from now on:

node subscribe-catchup-all-events.js

To generate a test event, open a separate console and run:

node store-event.js

Running the tests

To run the tests it is recommended that you use an in-memory instance of the eventstore so you don't pollute your dev instance.

EventStore.ClusterNode.exe --memdb

To execute the tests suites simply run

npm test

Porting .Net Task to Node.js

Any async commands returns a Promise object in replacement of .Net Task.

License

Ported code is released under the MIT license, see LICENSE.

Original code is released under the EventStore license and can be found at https://github.com/eventstore/eventstore.