ges-client

0.10.0 • Public • Published

ges-client

Gitter

A nodejs client library for (Get) Event Store

Build Status

NPM NPM

Want to help out? Check out a waiting issue Stories in Ready

Introduction

This client assumes that you already have an Event Store instance running.

Basic usage

Install

$ npm install ges-client

Append and read from an event stream

var ges = require('ges-client')
 
// 1) Create a connection to a running EventStore
//    using default connection options and credentials
var connection = ges()
    , stream = 'intro-events'
 
// 2) Append events that can be read
connection.on('connect', function() {
    var appendData = {
          expectedVersion: ges.expectedVersion.emptyStream
        , events: [array of events]
            }
    connection.appendToStream(stream, appendData, function(err, appendResult) {
      if(err) return console.log('Ooops!', err) // connection error
  
      // 3) Read first events from the stream
   connection.readStreamEventsForward(stream, { start: 0, count: 1 }, function(err, readResult) {
        if(err) return console.log('Ooops!', err) // connection error or stream does not exist
 
        // ta da!
   console.log(readResult.Events)
   })
  })
})

Subscribe to stream updates

var ges = require('ges-client')
 
// 1) Create a connection to a running EventStore
//    using default connection options and credentials
var connection = ges()
    , stream = 'intro-events'
 
// 2) Create a subscription
connection.on('connect', function() {
  var subscription = connection.subscribeToStream(stream)
 
    // 3) Listen for events
  subscription.on('event', function(evt) {
   // ta da!
   console.log(evt)
  })
 
    var appendData = {
          expectedVersion: ges.expectedVersion.emptyStream
        , events: [array of events]
            }
    connection.appendToStream(stream, appendData, function(err, appendResult) {
      if(err) return console.log('Ooops!', err) // connection error
  })
})

Major Feature Status

  • Connection (Partial - not all events are available)
  • Append to stream (Complete)
  • Read from stream (Complete)
  • Subscriptions (Complete)
  • Read from all (Complete)
  • Stream ACLs (Not Started)
  • Transactions (Complete)
  • Stream deletes (Complete)
  • Stream metadata (Complete)

License & copyright

Copyright (c) 2014 Brian Mavity.

ges-client is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.

Special Thanks

Special thanks to Ken Pratt for writing the first version of this over at https://github.com/kenpratt/nodejs-EventStore . It made early development go by much faster.

Readme

Keywords

none

Package Sidebar

Install

npm i ges-client

Weekly Downloads

2

Version

0.10.0

License

MIT +no-false-attribs, +no-advertising License

Last publish

Collaborators

  • bmavity