Socket
Socket
Sign inDemoInstall

@acuris/eventstore-api

Package Overview
Dependencies
2
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @acuris/eventstore-api

API for accessing event stores


Version published
Weekly downloads
1.8K
decreased by-15.54%
Maintainers
3
Install size
116 kB
Created
Weekly downloads
 

Readme

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

Last updated on 29 Feb 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc