Git Product home page Git Product logo

eventstore-client-nodejs's Introduction

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.

Note: This client is currently under active development and further API changes are expected. Feedback is very welcome.

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 here EventStoreDB Docs, follow the docker setup for the simplest configuration.

Example

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

Javascript example:
const {
  EventData,
  EventStoreConnection,
  writeEventsToStream,
  readEventsFromStream,
} = require("@eventstore/db-client");

const connection = EventStoreConnection.builder()
  .insecure()
  .singleNodeConnection("localhost:2113");

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

  const event = EventData.json("grpc-client", {
    languages: ["typescript", "javascript"],
    runtime: "NodeJS",
  }).build();

  const writeResult = await writeEventsToStream(streamName)
    .send(event)
    .execute(connection);

  const events = await readEventsFromStream(streamName)
    .fromStart()
    .forward()
    .count(10)
    .execute(connection);

  events.forEach(doSomethingProductive);
}
Typescript example:
import {
  EventData,
  EventStoreConnection,
  writeEventsToStream,
  readEventsFromStream,
} from "@eventstore/db-client";

const connection = EventStoreConnection.builder()
  .insecure()
  .singleNodeConnection("localhost:2113");

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

  const event = EventData.json("grpc-client", {
    languages: ["typescript", "javascript"],
    runtime: "NodeJS",
  }).build();

  const writeResult = await writeEventsToStream(streamName)
    .send(event)
    .execute(connection);

  const events = await readEventsFromStream(streamName)
    .fromStart()
    .forward()
    .count(10)
    .execute(connection);

  events.forEach(doSomethingProductive);
}

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.

$ yarn test

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

$ yarn cross-env EVENTSTORE_IMAGE=77d63f3f0ab3 jest

Support

Information on support can be found here: EventStoreDB Support

Documentation

Documentation for EventStoreDB can be found here: EventStoreDB Docs

Bear in mind that this client is not yet properly documented. We are working hard on a new version of the documentation.

Community

We have a community discussion space at EventStoreDB 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.