Socket
Book a DemoInstallSign in
Socket

@idot-digital/eventsdb-grpc-client

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@idot-digital/eventsdb-grpc-client

TypeScript gRPC client for EventsDB

0.0.1
latest
npmnpm
Version published
Maintainers
2
Created
Source

EventsDB gRPC TypeScript Client

A Node.js TypeScript client for EventsDB. It uses the gRPC protocol to communicate with the EventsDB server.

Installation

npm install

Building

First, generate the TypeScript types from the proto file:

npm run generate

Then build the project:

npm run build

Usage

import { EventsDBClient } from "./dist";

// Create a client instance without authentication or TLS
const client = new EventsDBClient({
  address: "localhost:50051",
});

// Create a client with authentication
const clientWithAuth = new EventsDBClient({
  address: "localhost:50051",
  token: "your-auth-token",
});

// Create a client with both authentication and TLS
const clientWithTLS = new EventsDBClient({
  address: "localhost:50051",
  token: "your-auth-token",
  tlsCertFile: "/path/to/cert.pem",
  tlsKeyFile: "/path/to/key.pem",
});

// Create an event
const eventId = await client.createEvent(
  "test-source",
  "test-type",
  "test-subject",
  Buffer.from("test-data")
);
console.log("Created event with ID:", eventId);

// Get an event
const event = await client.getEventByID(1);
console.log("Retrieved event:", event);

// Stream events
const stream = client.streamEventsFromSubject("test-subject", {
  recursive: true,
});
stream.subscribe({
  next: (response) => {
    console.log("Received events:", response.events);
  },
  error: (error) => {
    console.error("Stream error:", error);
  },
  complete: () => {
    console.log("Stream completed");
  },
});

API Reference

EventsDBClient

Constructor

constructor(config: EventsDBClientConfig)

Creates a new client instance. The config object accepts the following properties:

  • address: The server address in the format host:port (required)
  • token: Authentication token (optional)
  • tlsCertFile: Path to TLS certificate file (optional)
  • tlsKeyFile: Path to TLS key file (optional)

Methods

createEvent(source: string, type: string, subject: string, data: Buffer): Promise<number>

Creates a new event and returns its ID.

getEventByID(id: number): Promise<Event>

Retrieves an event by its ID.

streamEventsFromSubject(subject: string, options?: { type?: string; fromId?: number; recursive?: boolean }): Observable<StreamEventsFromSubjectReply>

Streams events for a given subject. The options parameter is optional and can include:

  • type: Filter events by type
  • fromId: Start streaming from a specific event ID
  • recursive: Whether to include events from child subjects

Authentication

The client supports token-based authentication. To use authentication:

  • Set the token property in the client configuration
  • The token will be automatically added to all requests as an authorization header

TLS Support

The client supports TLS connections. To use TLS:

  • Provide the paths to your TLS certificate and key files in the client configuration
  • The client will automatically establish a secure connection using these credentials

Note: If TLS files are not provided, the client will use an insecure connection.

FAQs

Package last updated on 26 May 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.