@galaxy-stack/orbit-sse
v0.6.0
Published
Server-Sent Events for Orbit — sseResponse helper, SseHub broadcaster, @Sse decorator metadata
Readme
@galaxy-stack/orbit-sse
Server-Sent Events for Orbit — sseResponse helper, SseHub broadcaster, @Sse decorator.
Part of the Orbit framework — a NestJS-style backend framework for Bun.
Installation
bun add @galaxy-stack/orbit-sseUsage
import { sseResponse, SseHub, type SseMessage } from '@galaxy-stack/orbit-sse';
// Stream an async iterable
async function* events(): AsyncGenerator<SseMessage> {
yield { event: 'tick', data: { t: Date.now() } };
}
const response = sseResponse(events()); // text/event-stream Response
// Or broadcast via a hub
const hub = new SseHub();
const res = hub.stream(); // attach to a route
hub.broadcast({ event: 'msg', data: { hello: 'world' } });License
MIT
