@fanoutio/eventstream
Version:
Connect-compatible middleware that enables the easy creation of EventStream endpoints
26 lines • 1.5 kB
TypeScript
import type { IncomingMessage, ServerResponse } from 'node:http';
import CallableInstance from 'callable-instance';
import IChannelsBuilder from './data/IChannelsBuilder.js';
import IEventStreamConfig from './data/IEventStreamConfig.js';
import IServerSentEvent from './data/IServerSentEvent.js';
import ChannelPublisher from './ChannelPublisher.js';
type NextFunction = (e?: Error) => void;
type HandlerFunction = (req: IncomingMessage, res: ServerResponse, fn: NextFunction) => Promise<void>;
type RouteParams = string[] | [string[]] | [IChannelsBuilder];
export default class EventStream extends CallableInstance<RouteParams, HandlerFunction> {
private readonly addressedEvents;
private readonly channelPublishers;
private readonly serveGrip?;
constructor(params: IEventStreamConfig | null);
publishEvent(channel: string, event: IServerSentEvent): Promise<void>;
getChannelPublisher(channel: string): ChannelPublisher;
createChannelWritable(channel: string): import("./stream/ChannelWritable.js").default;
private buildChannels;
route(...channelNames: string[]): HandlerFunction;
route(channelNames: string[]): HandlerFunction;
route(channelBuilder: IChannelsBuilder): HandlerFunction;
run(req: IncomingMessage, res: ServerResponse, channels: string | string[]): Promise<void>;
}
export declare function getEventStreamSingleton(params: IEventStreamConfig | null, singletonKey?: string): any;
export {};
//# sourceMappingURL=EventStream.d.ts.map