Getting Started
Prerequisite: Chronicle Kernel
Section titled “Prerequisite: Chronicle Kernel”You need a running Chronicle Kernel before connecting with the TypeScript client.
The easiest local setup is the development Docker image:
docker run -p 35000:35000 cratis/chronicle:latest-developmentInstallation
Section titled “Installation”yarn add @cratis/chronicle reflect-metadataNote:
reflect-metadatais required for TypeScript decorators to work at runtime. Import it once at the entry point of your application.
Import reflect-metadata at the top of your application entry point:
import 'reflect-metadata';Connecting to Chronicle
Section titled “Connecting to Chronicle”Create a ChronicleClient with a connection string pointing to your Chronicle Kernel instance:
import { ChronicleClient, ChronicleOptions } from '@cratis/chronicle';
const options = ChronicleOptions.fromConnectionString('chronicle://localhost:35000');const client = new ChronicleClient(options);
// Get an event storeconst store = await client.getEventStore('MyStore');
// ... use the store
// Always dispose when doneclient.dispose();Connection String Format
Section titled “Connection String Format”Chronicle connection strings use the chronicle:// scheme:
chronicle://localhost:35000chronicle://username:password@chronicle.example.com:35000Development Mode
Section titled “Development Mode”For local development, use:
const options = ChronicleOptions.development();This connects to chronicle://localhost:35000 by default.
Where to next
Section titled “Where to next”- Events and event logs, Event Types, and Event Evolution to model and evolve your event schema.
- Reducers, Reactors, and Projections to build read models and side effects from your events.
- Read Models to query projected state.
- Event Seeding and Transactions for test data and unit-of-work semantics.
- Compliance for PII handling and GDPR erasure.