Quick Start
The following provides a quick introduction on how to get started with @valkyr/event-store.
Setup
This project is published at The JavaScript Registry providing support for deno, bun, and node.js
Events
Our solution currently created to serve multiple platforms. As such we needed a way to easily take a central source of truth and generate platform specific outputs. For this we introduce a configuration approach using JSON files, and event generators.
First define one or more event folders which will house your applications events. In this example we simply create an events
folder.
Now that we have our events folder we move into it and create our first event.
We now open the JSON file and add our event configuration.
With this we should now have a folder events
with a user-create.json
configuration file. With this in place we can now create an event printer.
Printer
To convert our JSON configurations into event store consumable code, we need to create a new file which prints our configuration to code.
In our example we will start by creating a new generate file.
Then we add in the code to print our events.
Executing this file will now consume the events folder and create a events.ts file which represents all the events for our application.
The output should look something like the following:
Event Store
Our current output target is only TypeScript
with support for postgres
, sqlite
, and browsers
.
Now that we have our events.ts
file, we can instantiate a new event store and apply our events. First start by creating a new event-store.ts
file.
We open the new file and create our event store instance, in this example we will be using the sqlite
driver.
And with this, we have create our initial event store instance for use in our application.
Before we can use the event store instance we need to migrate the event store tables onto our application databases. See the migrate section for more information.
Last updated