All Projects → EventStore → EventStore-Client-NodeJS

EventStore / EventStore-Client-NodeJS

Licence: Apache-2.0 license
A NodeJS client for Event Store

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to EventStore-Client-NodeJS

Eventflow.example
DDD+CQRS+Event-sourcing examples using EventFlow following CQRS-ES architecture. It is configured with RabbitMQ, MongoDB(Snapshot store), PostgreSQL(Read store), EventStore(GES). It's targeted to .Net Core 2.2 and include docker compose file.
Stars: ✭ 131 (-5.76%)
Mutual labels:  eventstore, eventsourcing
Bifrost
This is the stable release of Dolittle till its out of alpha->beta stages
Stars: ✭ 111 (-20.14%)
Mutual labels:  eventstore, eventsourcing
Aggregates.net
.NET event sourced domain driven design model via NServiceBus and GetEventStore
Stars: ✭ 261 (+87.77%)
Mutual labels:  eventstore, eventsourcing
Todomvc Ddd Cqrs Eventsourcing
Implementation of basic Todo app via tastejs/todomvc in C#/Typescript with eventsourcing, cqrs, and domain driven design
Stars: ✭ 134 (-3.6%)
Mutual labels:  eventstore, eventsourcing
Kitsvc
⚙ 一個基於 Golang、Consul、Prometheus、EventStore、Gin、Gorm、NSQ 的微服務起始結構。
Stars: ✭ 101 (-27.34%)
Mutual labels:  eventstore, eventsourcing
factcast
This project is archived. A friendly fork can be found at https://github.com/factcast/factcast/
Stars: ✭ 14 (-89.93%)
Mutual labels:  eventstore, eventsourcing
Eshoponcontainersddd
Fork of dotnet-architecture/eShopOnContainers in full DDD/CQRS design using my own patterns
Stars: ✭ 126 (-9.35%)
Mutual labels:  eventstore, eventsourcing
eventuous
Minimalistic Event Sourcing library for .NET
Stars: ✭ 236 (+69.78%)
Mutual labels:  eventstore, eventsourcing
Jes
Java Event Store implementation
Stars: ✭ 32 (-76.98%)
Mutual labels:  eventstore, eventsourcing
Eventstore
The stream database optimised for event sourcing
Stars: ✭ 4,395 (+3061.87%)
Mutual labels:  eventstore, eventsourcing
les
Go directly from an event storming to a working API: Event Markdown / Markup validation & NodeJS CQRS/ES application builder.
Stars: ✭ 48 (-65.47%)
Mutual labels:  eventstore, eventsourcing
Event Store Client
PHP 7.4 Event Store Client Implementation
Stars: ✭ 93 (-33.09%)
Mutual labels:  eventstore, eventsourcing
eventsource-api
Provides an eventsourcing high level API.
Stars: ✭ 12 (-91.37%)
Mutual labels:  eventstore, eventsourcing
Eventstore
EventStore Haskell TCP Client
Stars: ✭ 77 (-44.6%)
Mutual labels:  eventstore, eventsourcing
rxeventstore
RxEventStore is a module for persisting and querying data using the Event Sourcing pattern and RxJs.
Stars: ✭ 26 (-81.29%)
Mutual labels:  eventstore, eventsourcing
Cosmostore
F# Event store for Azure Cosmos DB, Table Storage, Postgres, LiteDB & ServiceStack
Stars: ✭ 154 (+10.79%)
Mutual labels:  eventstore, eventsourcing
nestjs-boilerplate-microservice
Nestjs Microservice boilerplate: apply DDD, CQRS, and Event Sourcing within an event driven architecture
Stars: ✭ 270 (+94.24%)
Mutual labels:  eventstore, eventsourcing
Sequent
CQRS & event sourcing framework for Ruby
Stars: ✭ 400 (+187.77%)
Mutual labels:  eventstore, eventsourcing
workflow
Functional CQRS Eventsourcing Engine
Stars: ✭ 22 (-84.17%)
Mutual labels:  eventstore, eventsourcing
Eventflow
Async/await first CQRS+ES and DDD framework for .NET
Stars: ✭ 1,932 (+1289.93%)
Mutual labels:  eventstore, eventsourcing

npm Github action CI workflow license

EventStoreDB NodeJS Client

EventStoreDB is the open-source, functional database with Complex Event Processing in Javascript.

This is the repository for the NodeJS client for EventStoreDB 20+ and uses gRPC as the communication protocol.

Installation

# Yarn
$ yarn add @eventstore/db-client

# NPM
$ npm install --save @eventstore/db-client

EventStoreDB Server Compatibility

This client is compatible with version 20.6.1 upwards.

Server setup instructions can be found in the Event Store Docs, follow the docker setup for the simplest configuration.

Documentation

Full documentation can be found in Event Store GRPC Client Docs.

Example

The following snippet showcases a simple example where we form a connection, then append and read events from the server.

Javascript example:
const {
  EventStoreDBClient,
  jsonEvent,
  FORWARDS,
  START,
} = require("@eventstore/db-client");

const client = new EventStoreDBClient({
  endpoint: "localhost:2113",
});

async function simpleTest() {
  const streamName = "es_supported_clients";

  const event = jsonEvent({
    type: "grpc-client",
    data: {
      languages: ["typescript", "javascript"],
      runtime: "NodeJS",
    },
  });

  const appendResult = await client.appendToStream(streamName, [event]);

  const events = client.readStream(streamName, {
    fromRevision: START,
    direction: FORWARDS,
    maxCount: 10,
  });

  for await (const event of events) {
    doSomethingProductive(event);
  }
}
Typescript example:
import {
  EventStoreDBClient,
  jsonEvent,
  FORWARDS,
  START,
  JSONEventType,
} from "@eventstore/db-client";

const client = new EventStoreDBClient({
  endpoint: "localhost:2113",
});

interface Reservation {
  reservationId: string;
  movieId: string;
  userId: string;
  seatId: string;
}

type SeatReservedEvent = JSONEventType<
  "seat-reserved",
  {
    reservationId: string;
    movieId: string;
    userId: string;
    seatId: string;
  }
>;

type SeatChangedEvent = JSONEventType<
  "seat-changed",
  {
    reservationId: string;
    newSeatId: string;
  }
>;

type ReservationEvents = SeatReservedEvent | SeatChangedEvent;

async function simpleTest(): Promise<void> {
  const streamName = "booking-abc123";

  const event = jsonEvent<SeatReservedEvent>({
    type: "seat-reserved",
    data: {
      reservationId: "abc123",
      movieId: "tt0368226",
      userId: "nm0802995",
      seatId: "4b",
    },
  });

  const appendResult = await client.appendToStream(streamName, event);

  const events = client.readStream<ReservationEvents>(streamName, {
    fromRevision: START,
    direction: FORWARDS,
    maxCount: 10,
  });

  const reservation: Partial<Reservation> = {};

  for await (const { event } of events) {
    switch (event.type) {
      case "seat-reserved": {
        reservation.reservationId = event.data.reservationId;
        reservation.movieId = event.data.movieId;
        reservation.seatId = event.data.seatId;
        reservation.userId = event.data.userId;
        break;
      }
      case "seat-changed": {
        reservation.seatId = event.data.newSeatId;
        break;
      }
      default: {
        const _exhaustiveCheck: never = event;
        break;
      }
    }
  }
}

Build from source

This project uses Yarn as a build tool. The following shell command lines should get you started:

$ yarn
$ yarn build

Run tests

Tests are written using Jest and require Docker and Docker Compose to be installed. Then run test with:

$ yarn test

Tests can be filtered by prepending the test file or folder to the command

$ yarn test connection // all connection tests
$ yarn test ReadAll // only the ReadAll tests

To get debug information when running tests use the test:debug command.

$ yarn test:debug // debug all tests
$ yarn test:debug ReadAll // only the ReadAll tests

Specific docker images can be specified via the enviroment variable EVENTSTORE_IMAGE.

$ yarn cross-env EVENTSTORE_IMAGE=77d63f3f0ab3 jest

See Jest documentation for more options.

Debugging

This project uses the debug module internally to log information about connections, options and GRPC requests. To see all the internal logs, set the DEBUG environment variable to esdb:* when launching your app. Logs can be further filtered with glob patterns, for example, only connection logs: esdb:connection, everything but grpc logs: esdb:*,-*:grpc.

You can set a few environment variables that will further change the behavior of the debug logging:

Name Purpose
DEBUG Enables/disables specific debugging namespaces.
DEBUG_COLORS Whether or not to use colors in the debug output.
DEBUG_DEPTH Object inspection depth.
DEBUG_FD File descriptor to write debug output to.
DEBUG_SHOW_HIDDEN Shows hidden properties on inspected objects.

Note: The environment variables beginning with DEBUG_ end up being converted into an Options object that gets used with %o/%O formatters. See the Node.js documentation for util.inspect() for the complete list.

Support

Information on support can be found on our website: Event Store Support

Community

We have a community discussion space at Event Store Discuss.

Contributing

Development is done on the master branch. We attempt to do our best to ensure that the history remains clean and to do so, we generally ask contributors to squash their commits into a set or single logical commit.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].