@jolly-pixel/event-store
v3.0.0
Published
Append-only log for JollyPixel's events
Readme
💃 Getting Started
This package is available in the Node Package Repository and can be easily installed with npm or yarn.
$ npm i @jolly-pixel/event-store
# or
$ yarn add @jolly-pixel/event-store👀 Usage example
import * as EventStore from "@jolly-pixel/event-store";
const store = EventStore.persistence.memory();
store.writer.append({
assetType: "pixelart",
assetId: "<UUID>",
eventType: "pixelart.command",
eventData: {
action: "uv-region-moved",
metadata: {},
clientId: "533454a2-4f09-47c5-8e24-dc5d479c578e",
timestamp: 1788814248122
},
actor: {
type: "user",
id: "533454a2-4f09-47c5-8e24-dc5d479c578e"
}
}).unwrap();
const events = store.reader.list("<UUID>");
console.log(events);📚 API
All backends expose the same EventStore API.
📦 Persistence
Each factory returns a writer and a reader sharing the same storage, plus lifecycle close().
import * as EventStore from "@jolly-pixel/event-store";
EventStore.persistence.memory();
await EventStore.persistence.sqlite();[!NOTE] The package entrypoint is safe to import from browser code.
persistence.sqliteloads its Node-only backend when called.
📈 Benchmarks
$ npm run bench -w @jolly-pixel/event-store
$ npm run bench -w @jolly-pixel/event-store -- readSuites live in bench/ and run on the shared @jolly-pixel/bench
harness. They cover append, the reader, listFromCheckpoints against
listAll, and compact, over three backends: memory, sqlite:memory and
sqlite:file.
✨ Contributors guide
If you are a developer looking to contribute to the project, you must first read the CONTRIBUTING guide.
Run these commands from the monorepo root:
$ npm run test -w @jolly-pixel/event-store
$ npm run lint[!CAUTION] In case you introduce a new feature or fix a bug, make sure to include tests for it as well.
📃 License
MIT
