Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@acuris/eventstore-api

Package Overview
Dependencies
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@acuris/eventstore-api

API for accessing event stores

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

Eventstore API

Based on

  • https://github.com/tim-group/tg-eventstore (Java)
  • https://github.com/araqnid/eventstore (Kotlin)

Usage

Reading a stream:

async function listTransactionHistory(transactionId: string, eventSource: EventSource): Promise<{timestamp: Date, data: Transaction}> {
  return lastValueFrom(
      eventSource.streamReader.readStreamForwards({category: "transaction", id: transactionId})
        .pipe(toArray(), map(re => ({timestamp: re.event.timestamp, data: re.event.data as Transaction})))
  )
}

Reading entire store:

return new Promise(((resolve, reject) => {
    let lastPosition = position
    eventSource.storeReader.readAll(position).subscribe(
      re => {
        ingestTransaction(re.event.data as Transaction)
        lastPosition = re.position
      },
      err => reject("Failed to read all transactions since " + lastPosition + ": " + err),
      () => resolve(lastPosition)
    )
}))

Code Formatting with Prettier

Recommend you use prettier for formatting so that we have a consistent code style.

If you are using IntelliJ then install the Prettier plugin. You can config it to run when you normally run format (see Languages & Frameworks > Javascript > Prettier and check "Run on 'Reformat Code' action")

Keywords

FAQs

Package last updated on 29 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc