@doughtnerd/message-store-connector
v1.10.1
Published
NodeJS client library for Eventide Project's Message DB
Downloads
93
Maintainers
Readme
Message Store Connector
These docs are under active development, as the library develops, better docs will be added.
What is it?
NodeJS library to connect to and operate on Eventide Project's Message DB.
Why is it?
A long time ago, in a galaxy far far away I worked at a company that used Event Sourcing and CQRS - specifically utilizing Eventide's Message DB. In that company we had a JS Message DB client library supporting usage of Message DB. I really enjoyed using that library and couldn't find a better equivalent in the wild. Since I've now left that company and the proprietary library behind, I figured it would be a good idea to make my own library to facilitate my personal usage of Message DB in hobby projects.
How do I use it?
Installation
Via npm
npm install @doughtnerd/message-store-connector
Via yarn
yarn add @doughtnerd/message-store-connector
Code Usage
Connect
Everything starts with a connection.
Specifically the main export of the library is this connect
function:
import { connect } from '@doughtnerd/message-store-connector';
The connect function takes a single config argument, which looks like this:
const messageStoreConfig = {
messageStoreHost: 'localhost', // Or wherever your MessageDB is
messageStorePassword: 'password', // Or whatever your actual password is
logger: console, // The logger you want the library to use internally
};
Put it all together and you have this:
import { connect } from '@doughtnerd/message-store-connector';
const messageStoreConfig = {
messageStoreHost: 'localhost',
messageStorePassword: 'password',
logger: console,
};
connect(messageStoreConfig).then(messageStore => {
// Do the things!
})
Call all the functions!
The library supports most of the MessageDB interactions listed here
Once you have your connection, you can use the messageStore
object to interact with your MessageDB.
connect(messageStoreConfig).then(async (messageStore) => {
const streamName = 'rickRoll-43cf527b-0fa1-433f-bad0-6834b927e243'
const event = {
id: '42b85f29-088e-4c53-8ba8-e2ffa9a239ea',
type: 'UserWasRickRolled',
data: {
neverGonna: [
'Give you up',
'Let you down',
'Turn around and forget you'
]
},
metadata: {}
}
await messageStore.writeMessage(streamName, event)
})