Go to file
2016-10-31 09:25:27 -07:00
samples Samples: Storing events and subscribing. 2016-10-31 09:25:27 -07:00
src Bumping version to 0.0.7, exposing loggers, minor bug fixes, cluster connection (wip) 2016-10-20 04:40:46 -07:00
test Bumping version to 0.0.7, exposing loggers, minor bug fixes, cluster connection (wip) 2016-10-20 04:40:46 -07:00
.gitignore Getting started example 2016-10-29 14:30:39 -07: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 Bumping version to 0.0.7, exposing loggers, minor bug fixes, cluster connection (wip) 2016-10-20 04:40:46 -07:00
README.md Brevity. 2016-10-29 16:41:08 -07: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

Dependencies

Status

Unstable

Missing features:

  • Ssl connection
  • Cluster connection
  • Set system settings

Incomplete

  • Typed errors: currently most errors are direct instance of Error, which is not practical for error handling
  • Performance: there's still some while loop in the code that could be problematic with node.js
  • Tests: tests are only covering happy path scenarios for now

Getting started

Install & run 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({}, {"hostname": "localhost", "port": 1113});
esConnection.connect();
esConnection.once('connected', function (tcpEndPoint) {
    console.log('Connected to eventstore at ' + tcpEndPoint.hostname + ":" + 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

Porting .Net Task to Node.js

.Net Task have been replace with Promise. When executing an async command, i.e. appendToStream you can use then/catch to wait for result/error.

Running the tests

To run the tests you will need

  • To install the dependencies (npm install)
  • Run an instance of EventStore >= 3.3.0 (competing consumers are required for test) on localhost:1113 (Download here)

To execute the tests suites simply run test with npm

npm test

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.