Registry / database / fact-streams

fact-streams

JSON →
library0.3.0jsnpmunverified

Fact-streams is a TypeScript library for building event-sourced applications with Node.js and MongoDB. Current stable version is 0.3.0. It offers an alternative to the CRUD paradigm by providing a toolkit for event sourcing and CQRS patterns. The library ships with TypeScript types and focuses on simplicity and developer experience, with documented concepts and example models.

npm install fact-streams
INSTALL
IMPORT
SIG · FACT-STREAMS
F
fact-streams
databasejavascriptv0.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FactStream
import { FactStream } from 'fact-streams'
const FactStream = require('fact-streams').FactStream
ESM-only; CommonJS require may break.
EventStore
import { EventStore } from 'fact-streams'
const { EventStore } = require('fact-streams')
Named import; TypeScript types included.
Command
import { Command } from 'fact-streams'
import Command from 'fact-streams'
Command is a named export, not default.

Shows how to connect to MongoDB, define a command, execute it, and store an event.

import { FactStream, EventStore, Command } from 'fact-streams'; const eventStore = new EventStore({ url: process.env.MONGO_URL || 'mongodb://localhost:27017' }); class CreateUser extends Command { constructor(public userId: string, public name: string) { super(); } } const factStream = new FactStream({ eventStore }); await factStream.connect(); const event = await factStream.execute(new CreateUser('123', 'Alice')); console.log('Event stored:', event);
Debug
Known issues
breakingAPI changed between 0.2.x and 0.3.0: EventStore constructor now requires a url option.
fix
Update constructor to include { url: '...' }.
affects: <0.3.0
gotchaEventStore does not automatically create indexes; manual index creation may be required.
fix
Run ensureIndexes() after connecting.
affects: >=0.1.0
deprecatedThe 'factStream.emit' method is deprecated in favor of 'factStream.execute' since 0.3.0.
fix
Replace emit() with execute().
affects: <0.3.0
Errors
Common errors & fixes
MongoError: E11000 duplicate key error
Duplicate event ID due to re-execution.
fix
Ensure commands are idempotent or use unique constraints.
TypeError: FactStream is not a constructor
Incorrect import: using default import instead of named.
fix
Use import { FactStream } from 'fact-streams'.
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
mongodbrequiredRequired for MongoDB persistence
Agent activity
8 hits · last 30 days
node
6
Resources
fact-streams — npm install fact-streams · libregistry