• Stars
    star
    1,073
  • Rank 43,114 (Top 0.9 %)
  • Language
    TypeScript
  • License
    GNU Affero Genera...
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

wolkenkit is an open-source CQRS and event-sourcing framework based on Node.js, and it supports JavaScript and TypeScript.

wolkenkit

wolkenkit is a CQRS and event-sourcing framework based on Node.js. It empowers you to build and run scalable distributed web and cloud services that process and store streams of domain events. It supports JavaScript and TypeScript, and is available under an open-source license. Additionally, there are also enterprise add-ons. Since it works especially well in conjunction with domain-driven design (DDD), wolkenkit is the perfect backend framework to shape, build, and run web and cloud APIs.

BEWARE: This README.md refers to the wolkenkit 4.0 community technology preview (CTP) 6. If you are looking for the latest stable release of wolkenkit, see the wolkenkit documentation.

wolkenkit

Status

Category Status
Version npm
Dependencies David
Dev dependencies David
Build GitHub Actions
License GitHub

Quick start

First you have to initialize a new application. For this, execute the following command and select a template and a language. The application is then created in a new subdirectory:

$ npx [email protected] init <name>

Next, you need to install the application dependencies. To do this, change to the application directory and run the following command:

$ npm install

Finally, from within the application directory, run the application in local development mode by executing the following command:

$ npx wolkenkit dev

Please note that the local development mode processes all data in-memory only, so any data will be lost when the application is closed.

Sending commands, receiving domain events, and querying views

To send commands or receive domain events, the current version offers an HTTP and a GraphQL interface.

Using the HTTP interface

wolkenkit provides two primary endpoints in local development mode:

  • http://localhost:3000/command/v2/:contextName/:aggregateName/:commandName submits commands for new aggregates
  • http://localhost:3000/command/v2/:contextName/:aggregateName/:aggregateId/:commandName submits commands for existing aggregates
  • http://localhost:3000/views/v2/:viewName/:queryName queries views
  • http://localhost:3000/domain-events/v2 subscribes to domain events
  • http://localhost:3000/notifications/v2 subscribes to notifications

Additionally, the following secondary endpoints are available as well:

  • http://localhost:3000/command/v2/cancel cancels a submitted, but not yet handled command
  • http://localhost:3000/command/v2/description fetches a JSON description of all available commands
  • http://localhost:3000/domain-events/v2/description fetches a JSON description of all available domain events
  • http://localhost:3000/open-api/v2 provides an OpenAPI description of the HTTP interface
  • http://localhost:3001/health/v2 fetches health data
Sending commands

To send a command, send a POST request with the following JSON data structure in the body to the command endpoint of the runtime. Of course, the specific names of the context, the aggregate and the command itself, as well as the aggregate id and the command's data depend on the domain you have modeled:

{
  "text": "Hello, world!"
}

A sample call to curl might look like this:

$ curl \
    -i \
    -X POST \
    -H 'content-type: application/json' \
    -d '{"text":"Hello, world!"}' \
    http://localhost:3000/command/v2/communication/message/send

If you want to address an existing aggregate, you also have to provide the aggregate's id:

$ curl \
    -i \
    -X POST \
    -H 'content-type: application/json' \
    -d '{}' \
    http://localhost:3000/command/v2/communication/message/d2edbbf7-a515-4b66-9567-dd931f1690d3/like
Cancelling a command

To cancel a command, send a POST request with the following JSON data structure in the body to the cancel endpoint of the runtime. Of course, the specific names of the context, the aggregate and the command itself, as well as the aggregate id and the command's data depend on the domain you have modeled:

{
  "contentIdentifier": { "name": "communication" },
  "aggregateIdentifier": { "name": "message", "id": "d2edbbf7-a515-4b66-9567-dd931f1690d3" },
  "name": "send",
  "id": "<command-id>"
}

A sample call to curl might look like this:

$ curl \
    -i \
    -X POST \
    -H 'content-type: application/json' \
    -d '<json>' \
    http://localhost:3000/command/v2/cancel

Please note that you can cancel commands only as long as they are not yet being processed by the domain.

Querying a view

To query a view, send a GET request to the views endpoint of the runtime. The response is a stream of newline separated JSON objects, using application/x-ndjson as its content-type. This response stream does not contain heartbeats and ends as soon as the last item is streamed.

A sample call to curl might look like this:

$ curl \
    -i \
    http://localhost:3000/views/v2/messages/all
Subscribing to domain events

To receive domain events, send a GET request to the domain events endpoint of the runtime. The response is a stream of newline-separated JSON objects, using application/x-ndjson as its content-type. From time to time, a heartbeat will be sent by the server as well, which you may want to filter.

A sample call to curl might look like this:

$ curl \
    -i \
    http://localhost:3000/domain-events/v2
Subscribing to notifications

To receive notifications, send a GET request to the notifications endpoint of the runtime. The response is a stream of newline-separated JSON objects, using application/x-ndjson as its content-type. From time to time, a heartbeat will be sent by the server as well, which you may want to filter.

A sample call to curl might look like this:

$ curl \
    -i \
    http://localhost:3000/notifications/v2

Using the GraphQL interface

wolkenkit provides a GraphQL endpoint under the following address:

  • http://localhost:3000/graphql/v2

You can use it to submit commands and subscribe to domain events, however cancelling commands is currently not supported. If you point your browser to this endpoint, you will get an interactive GraphQL playground.

Sending commands

To send a command, send a mutation with the following data structure to the GraphQL endpoint of the runtime. Of course, the specific names of the context, the aggregate and the command itself, as well as the aggregate id and the command's data depend on the domain you have modeled:

mutation {
  command {
    communication_message_send(aggregateIdentifier: { id: "d2edbbf7-a515-4b66-9567-dd931f1690d3" }, data: { text: "Hello, world!" }) {
      id,
      aggregateIdentifier {
        id
      }
    }
  }
}
Cancelling a command

To cancel a command, send a mutation with the following data structure to the GraphQL endpoint of the runtime. Of course, the specific names of the context, the aggregate and the command itself, as well as the aggregate id and the command's data depend on the domain you have modeled:

mutation {
  cancel(commandIdentifier: {
    contextIdentifier: { name: "communication" },
    aggregateIdentifier: { name: "message", id: "d2edbbf7-a515-4b66-9567-dd931f1690d3" },
    name: "send",
    id: "0a2d394c-2873-4643-84fd-dbcc43d80c5b"
  }) {
    success
  }
}

Please note that you can cancel commands only as long as they are not yet being processed by the domain.

Querying a view

To query a view, send a query to the GraphQL endpoint of the runtime:

query {
  messages {
    all {
      id
      timestamp
      text
      likes
    }
  }
}
Subscribing to domain events

To receive domain events, send a subscription to the GraphQL endpoint of the runtime. The response is a stream of objects, where the domain events' data has been stringified:

subscription {
  domainEvents {
    contextIdentifier { name },
    aggregateIdentifier { name, id },
    name,
    id,
    data
  }
}
Subscribing to notifications

To receive notifications, send a subscription to the GraphQL endpoint of the runtime. The response is a stream of objects, where the domain events' data has been stringified:

subscription {
  notifications {
    name,
    data
  }
}

Managing files

wolkenkit provides a file storage service that acts as a facade to a storage backend such as S3 or the local file system. It can be addressed using an HTTP API.

Using the HTTP interface

wolkenkit provides three primary endpoints in local development mode:

  • http://localhost:3000/files/v2/add-file adds a file
  • http://localhost:3000/files/v2/file/:id gets a file
  • http://localhost:3000/files/v2/remove-file removes a file
Adding files

To add a file, send a POST request with the file to be stored in its body to the add-file endpoint of the runtime. Send the file's id, its name and its content type using the x-id, x-name and content-type headers.

A sample call to curl might look like this:

$ curl \
    -i \
    -X POST \
    -H 'x-id: 03edebb0-7a36-4902-a082-ef979982a12c' \
    -H 'x-name: hello.txt' \
    -H 'content-type: text/plain' \
    -d 'Hello, world!' \
    http://localhost:3000/files/v2/add-file
Getting files

To get a file, send a GET request with the file id as part of the URL to the file endpoint of the runtime.

A sample call to curl might look like this:

$ curl \
    -i \
    http://localhost:3000/files/v2/file/03edebb0-7a36-4902-a082-ef979982a12c

You will get the file's id, name and its content-type in the x-id, x-name and content-type headers.

Removing files

To remove a file, send a POST request with the following JSON structure to the remove-file endpoint of the runtime:

{
  "id": "03edebb0-7a36-4902-a082-ef979982a12c"
}

A sample call to curl might look like this:

$ curl \
    -i \
    -X POST \
    -H 'content-type: application/json' \
    -d '{"id":"03edebb0-7a36-4902-a082-ef979982a12c"}' \
    http://localhost:3000/files/v2/remove-file

Authenticating a user

For authentication wolkenkit relies on OpenID Connect, so to use authentication you have to set up an external identity provider such as Auth0 or Keycloak.

Configure it to use the implicit flow, copy its certificate to your application directory, and set the --identity-provider-issuer and --identity-provider-certificate flags when running npx wolkenkit dev. For details, see the CLI's integrated help. Please make sure that your identity provider issues token using the RS256 algorithm, otherwise wolkenkit won't be able to decode and verify the token.

If a user tries to authenticate with an invalid or expired token, they will receive a 401. If the user doesn't send a token at all, they will be given a token that identifies them as anonymous. By default, you can not differentiate between multiple anonymous users. If you need this, set the x-anonymous-id header in the client accordingly.

Packaging the application into a Docker image

To package the application into a Docker image, change to the application directory and run the following command. Assign a custom tag to name the Docker image:

$ docker build -t <tag> .

Then you can push the created Docker image into a registry of your choice, for example to use it in Kubernetes.

Run the application with docker-compose

Once you have built the Docker image, you can use docker-compose to run the application. The application directory contains a subdirectory named deployment/docker-compose, which contains ready-made scripts for various scenarios.

Basically, you can choose between the single-process runtime and the microservice runtime. While the former runs the entire application in a single process, the latter splits the different parts of the application into different processes, each of which you can then run on a separate machine.

Using docker-compose also allows you to connect your own databases and infrastructure components. For details see the respective scripts.

To start the microservice runtime with a PostgreSQL database for persistence, first start the stores:

$ docker-compose -f stores.postgres.yml up -d

Then run the setup service to prepare the stores and any infrastructure you have added (please note that this only needs to be done once):

$ docker-compose -f setup.postgres.yml run setup

This will show a warning about orphaned containers, which you can safely ignore. Lastly start your application:

$ docker-compose -f microservice.postgres.yml up

Configuring data stores

wolkenkit uses a number of stores to run your application. In the local development mode, these stores are all run in-memory, but if you run the application using Docker, you will probably want to use persistent data stores. The following databases are supported for the domain event store, the lock store, and the priority queue store:

  • In-memory
  • MariaDB
  • MongoDB
  • MySQL
  • PostgreSQL
  • Redis (only for the lock store)
  • SQL Server

Please note that MongoDB must be at least version 4.2, and that you need to run it as a replica set (a single node cluster is fine).

For details on how to configure the databases, please have a look at the source code. This will be explained in more detail in the final version of the documentation.

Getting help

Please remember that this version is a community technology preview (CTP) of the upcoming wolkenkit 4.0. Therefore it is possible that not all provided features work as expected or that some features are missing completely.

BEWARE: Do not use the CTP for production use, it's for getting a first impression of and evaluating the upcoming wolkenkit 4.0.

If you experience any difficulties, please create an issue and provide any steps required to reproduce the issue, as well as the expected and the actual result. Additionally provide the versions of wolkenkit and Docker, and the type and architecture of the operating system you are using.

Ideally you can also include a short but complete code sample to reproduce the issue. Anyway, depending on the issue, this may not always be possible.

Running the build

To build this module use roboter:

$ npx roboter

Running the fuzzer

There is some fuzzing for parts of wolkenkit. To run the fuzzer use:

$ npm run fuzzing

Running the fuzzer can take a long time. The usual time is about 5 hours. Detailed results for the fuzzing operations are written to /tmp.

Running a local development version of wolkenkit

If you are working on wolkenkit itself, you might want to run an application using your development version without publishing this version as a preview. For that, use the following commands:

# First, build your local development version
$ npx roboter build

# Next, switch to the directory that contains your wolkenkit application
$ cd <path-of-your-application>

# Run the previously compiled wolkenkit CLI with your application
$ npx node <path-to-wolkenkit-repository>/build/lib/bin/wolkenkit.js dev

Publishing an internal version

While working on wolkenkit itself, it is sometimes necessary to publish an internal version to npm, e.g. to be able to install wolkenkit from the registry. To publish an internal version run the following commands:

$ npx roboter build && npm version 4.0.0-internal.<id> && npm publish --tag internal && git push && git push --tags

More Repositories

1

node-eventstore

EventStore Implementation in node.js
JavaScript
539
star
2

node-cqrs-domain

Node-cqrs-domain is a node.js module based on nodeEventStore that. It can be very useful as domain component if you work with (d)ddd, cqrs, eventdenormalizer, host, etc.
JavaScript
269
star
3

wolkenkit-boards

wolkenkit-boards is a team collaboration application.
JavaScript
245
star
4

uuidv4

uuidv4 creates v4 UUIDs.
TypeScript
177
star
5

cqrs-sample

CQRS, EventSourcing, (DDDD) Sample in node.js
JavaScript
148
star
6

forcedomain

forcedomain is a middleware for Connect and Express that redirects any request to a default domain.
TypeScript
86
star
7

p2p

p2p implements a peer-to-peer protocol.
JavaScript
80
star
8

wolkenkit-eventstore

wolkenkit-eventstore is an open-source eventstore for Node.js that is used by wolkenkit.
JavaScript
79
star
9

roboter

roboter streamlines software development by automating tasks and enforcing conventions.
TypeScript
64
star
10

node-cqrs-saga

Node-cqrs-saga is a node.js module that helps to implement the sagas in cqrs. It can be very useful as domain component if you work with (d)ddd, cqrs, eventdenormalizer, host, etc.
JavaScript
61
star
11

get-next-version

get-next-version gets the next version for your repository according to semantic versioning based on conventional commits.
Go
45
star
12

flaschenpost

flaschenpost is a logger for cloud-based applications.
TypeScript
38
star
13

node-cqrs-eventdenormalizer

Node-cqrs-eventdenormalizer is a node.js module that implements the cqrs pattern. It can be very useful as eventdenormalizer component if you work with (d)ddd, cqrs, domain, host, etc.
JavaScript
38
star
14

boolean

boolean converts lots of things to boolean.
TypeScript
37
star
15

eslint-config-es

eslint-config-es contains a strict ESLint configuration for ES2015+ and TypeScript.
TypeScript
28
star
16

buntstift

buntstift makes the CLI colorful.
TypeScript
27
star
17

node-viewmodel

Node-viewmodel is a node.js module for multiple databases. It can be very useful if you work with (d)ddd, cqrs, eventdenormalizer, host, etc.
JavaScript
27
star
18

crypto2

crypto2 is a convenience wrapper around Node.js' crypto module.
JavaScript
25
star
19

vagrant-node

vagrant-node is the virtual machine used for Node.js development.
Shell
24
star
20

assertthat

assertthat provides fluent TDD.
TypeScript
24
star
21

techlounge-react

techlounge-react contains the samples for the free tech:lounge video course on React.
TypeScript
23
star
22

get-routes

get-routes gets all routes from an Express application.
TypeScript
22
star
23

get-graphql-from-jsonschema

get-graphql-from-jsonschema gets a GraphQL schema from a JSON schema.
TypeScript
22
star
24

tailwind

tailwind is a base module for streaming and evented CQS applications.
JavaScript
20
star
25

cases

cases provides parameterized unit tests for Mocha.
JavaScript
19
star
26

defekt

defekt is custom errors made simple.
TypeScript
19
star
27

tutum

tutum is a wrapper around Tutum's API for Node.js.
JavaScript
19
star
28

comparejs

comparejs implements JavaScript's comparison operators the way you would expect them to be.
TypeScript
18
star
29

commands-events

commands-events provides commands and events for DDD-based applications.
JavaScript
18
star
30

techlounge-docker

techlounge-docker contains the samples for the free tech:lounge video course on Docker.
JavaScript
17
star
31

wolkenkit-todomvc

wolkenkit-todomvc is a todo application.
JavaScript
16
star
32

node-evented-command

provides simple command/event handling for evented systems like cqrs
JavaScript
15
star
33

crew

crew makes managing Docker a breeze.
JavaScript
12
star
34

wolkenkit-nevercompletedgame

wolkenkit-nevercompletedgame is a wolkenkit implementation of nevercompletedgame.com.
JavaScript
11
star
35

json-lines

json-lines streams JSON Lines.
JavaScript
11
star
36

ensurethat

ensurethat validates function arguments.
JavaScript
10
star
37

wolkenkit-react

Official React bindings for wolkenkit.
JavaScript
9
star
38

cqrs

documentation for cqrs modules and libraries
JavaScript
9
star
39

thenativeweb-ux

thenativeweb-ux provides UI components for the native web applications.
TypeScript
9
star
40

runfork

runfork runs a Node.js script isolated as a process.
TypeScript
8
star
41

processenv

processenv parses environment variables.
TypeScript
8
star
42

isolated

isolated provides one-time folders for unit tests.
TypeScript
8
star
43

terminal-img

terminal-img renders an image to the terminal.
TypeScript
8
star
44

json-lines-client

json-lines-client makes parsing JSON lines streams a breeze.
JavaScript
7
star
45

bereich

bereich creates ranges of numbers.
JavaScript
7
star
46

timer2

timer2 is an evented timer.
JavaScript
7
star
47

validate-value

validate-value validates values against JSON schemas.
TypeScript
7
star
48

command-line-interface

command-line-interface is a foundation for CLI applications.
TypeScript
7
star
49

aira

aira runs loops on Roland AIRA series synthesizers.
TypeScript
7
star
50

knockat

knockat waits until a host is reachable.
TypeScript
6
star
51

measure-time

measure-time is a stopwatch.
TypeScript
6
star
52

tourism

tourism is a convenience wrapper for Grunt.
JavaScript
6
star
53

wolkenkit-documentation

wolkenkit-documentation provides the documentation for wolkenkit application developers.
JavaScript
6
star
54

wolkenkit-client-js

wolkenkit-client is a client to access wolkenkit applications.
JavaScript
5
star
55

partof

partof verifies whether one object is part of an other.
TypeScript
5
star
56

formats

formats is a collection of validators.
JavaScript
5
star
57

wolkenkit-core

wolkenkit-core is the domain server of wolkenkit.
JavaScript
5
star
58

nodeenv

nodeenv enables tests to control Node.js environment variables.
TypeScript
5
star
59

datasette

datasette is a key-value container for arbitrary data.
JavaScript
5
star
60

wolkenkit-vm

wolkenkit-vm is a Packer script to setup virtual machines that run wolkenkit.
Shell
5
star
61

findsuggestions

findsuggestions searches haystacks for needles and nails.
JavaScript
4
star
62

try-catch-expression

try-catch-expression provides try..catch as expression.
TypeScript
4
star
63

rdrct

rdrct is a URL shortener and redirection service.
TypeScript
4
star
64

reqd

reqd searches repositories for dependencies.
JavaScript
4
star
65

typedescriptor

typedescriptor identifies and describes types.
TypeScript
4
star
66

limes

limes authenticates users.
TypeScript
4
star
67

wolkenkit-chat-auth0

wolkenkit-chat-auth0 is a chat using wolkenkit and Auth0.
JavaScript
4
star
68

draht

draht provides process-level messaging.
JavaScript
4
star
69

walk-file-tree

walk-file-tree recursively fetches paths to files and directories.
TypeScript
3
star
70

sortby

sortby orders JavaScript arrays using a MongoDB-like syntax.
JavaScript
3
star
71

forany

forany runs a command on every directory.
JavaScript
3
star
72

dotfile-json

dotfile-json reads and writes dot files.
JavaScript
3
star
73

wolkenkit-vagrant

wolkenkit-vagrant provides a Vagrantfile to setup wolkenkit VMs.
3
star
74

flat-object-keys

flat-object-keys returns the flattened keys from an object.
JavaScript
3
star
75

zwitscher

zwitscher is a Twitter CLI.
JavaScript
3
star
76

datendepot

datendepot is a blob storage middleware.
JavaScript
3
star
77

wolkenkit-template-chat

wolkenkit-template-chat is an application template for wolkenkit.
JavaScript
3
star
78

record-stdstreams

record-stdstreams captures process.stdout and process.stderr.
TypeScript
3
star
79

marble-run

marble-run parallelizes asynchronous tasks while keeping some of them in order.
JavaScript
3
star
80

wait-for-signals

wait-for-signals waits for a number of signals before resolving a promise.
TypeScript
3
star
81

whatif

whatif discovers dependencies that need to be updated after updating a package.
JavaScript
3
star
82

update-node

update-node is a script to update repositories to a new Node.js version.
JavaScript
3
star
83

roboter-cli

roboter-cli is the CLI for roboter.
JavaScript
3
star
84

https-or-http

https-or-http runs an HTTPS server or, if not possible, an HTTP server.
JavaScript
2
star
85

deep-hash

deep-hash calculates nested hashes.
JavaScript
2
star
86

get-certificate

get-certificate loads a certificate and its private key from a directory.
JavaScript
2
star
87

shaker

shaker hashes and verifies passwords in a cryptographically secure way using PBKDF2.
JavaScript
2
star
88

streamtoarray

streamtoarray converts a stream to an array.
TypeScript
2
star
89

adventsspecial2021

adventsspecial2021 contains templates, code & co. for the advent special 2021.
JavaScript
2
star
90

isansi

isansi checks whether a string uses ANSI color and style.
TypeScript
2
star
91

temp--performance-workshop

JavaScript
2
star
92

temp--livestream-monitoring

Go
2
star
93

hase

hase handles exchanges and queues on RabbitMQ.
JavaScript
2
star
94

semantic-release-configuration

semantic-release-configuration contains the semantic-release configuration for the native web.
JavaScript
2
star
95

wolkenkit-broker

wolkenkit-broker is the public API server of wolkenkit.
JavaScript
2
star
96

tlse2021-fullstack-testen

tech:lounge Summer Edition 2021 // Fullstack-Testen – von der Unit bis zur UI
TypeScript
2
star
97

wolkenkit-depot

wolkenkit-depot is a service for storing large files.
JavaScript
2
star
98

wolkenkit-console

wolkenkit-console lets you execute domain code from within your browser.
JavaScript
2
star
99

is-subset-of

is-subset-of verifies whether an array or an object is a subset.
TypeScript
2
star
100

is-typescript

is-typescript checks whether a package is built using TypeScript.
TypeScript
1
star