Skip to content

Documentation / @eventkit/http

@eventkit/http is a package that provides HTTP utilities for eventkit.

Installation

sh
npm i @eventkit/http

Classes

ClassDescription
EventSourceA drop-in replacement for the standard EventSource class that provides an Observable interface for handling Server-Sent Events (SSE). This class extends the native EventSource class and adds the ability to consume events as an AsyncObservable using the asObservable method.
EventSourceResponseA Response subclass that subscribes to an AsyncObservable and streams the values yielded by the observable to the client as Server-Sent Events (SSE). Optional property selectors can be provided to customize the serialization of the events.
WebSocketA drop-in replacement for the standard WebSocket class that provides an Observable interface for handling WebSocket connections. This class extends the native WebSocket class and adds the ability to consume events as an AsyncObservable using the asObservable method.

Type Aliases

Type AliasDescription
EventSourceEventRepresents the different native event objects that can be emitted by an EventSource. This type union covers all possible event types: error, message, and open events.
EventSourceMessageRepresents a message event emitted by an EventSource.
EventSourceResponseInitConfiguration options for creating an EventSourceResponse. Extends the standard ResponseInit interface with SSE-specific options.
EventSourceSerializerInitConfiguration options for customizing how events are serialized into SSE format. Each property can be a function that extracts the corresponding SSE field from an event, or null to exclude that field from the output.

Functions

FunctionDescription
eventSourceObservableCreates an AsyncObservable from an EventSource instance.
websocketObservableCreates an AsyncObservable from a WebSocket instance.

Released under the MIT License.