API Reference
Types and options for @g14o/events.
EventBusOptions
Options for new Event({ … }). Schema-first mode also accepts schema (nested Standard Schema map) for validation and InferEvents — that field lives on the conditional CreateEventConfig, not on EventBusOptions itself.
| Option | Type | Description |
|---|---|---|
hooks? | | Lifecycle hooks for pipeline and error routing. |
onListenerError? | | How listener errors affect other listeners. "continue" |
strategy? | | Listener execution strategy. parallelStrategy |
stream? | | Cross-instance persistence and fan-out backend. |
verbose? | | Log pipeline steps to the console when false |
EventBusHooks
| Option | Type | Description |
|---|---|---|
onError? | | Initial |
onPipelineEnd? | | After middleware + listeners complete. |
onPipelineFinally? | | After pipeline attempt (success or failure). Skipped on validation failure. |
onPipelineStart? | | After validation, before middleware + listeners. |
onValidationError? | | Initial |
EventBus
Typed async-first event bus returned by new Event({ … }). See Server for emit/dispatch and SSE wiring, Listeners for on / once / subscribe, and Namespaces for namespace and channel scoping.
ChannelEmitter
Channel-scoped emitter from event.channel(...names) — same emit API with channels merged into metadata. See Channel for client subscribe and Server for emit.
EventHandlerOptions
Options for handler({ … }).
| Option | Type | Description |
|---|---|---|
authorizeJoin? | | Gate SSE channel join/leave before the connection is accepted. |
event | | Event bus instance to subscribe and replay from. |
maxDurationSecs? | | Max SSE connection duration in seconds before the server closes it. |
middleware? | | Run before subscribe; return a Response to reject the request. |
OnOptions
Options for on / once.
| Option | Type | Description |
|---|---|---|
priority? | | Higher runs first among listeners for the same event. 0 |
signal? | | Abort to unregister the listener when the signal fires. |
SubscribeEventOptions
Options-object form of server event.subscribe / channel.subscribe (channel-scoped form omits channels).
| Option | Type | Description |
|---|---|---|
signal? | | Abort to unsubscribe when the signal fires. |
channels? | | Channel names to scope delivery; omit for bus-wide subscribe. |
events | | Event names to listen for. |
once? | | Unsubscribe after the first matching delivery. |
onData | | Called for each matching event payload. |
priority? | | Higher runs first when multiple subscribers match. |
MemoryStreamOptions
| Option | Type | Description |
|---|---|---|
maxLength? | | Max messages retained per channel. 100 |
RedisStreamOptions
| Option | Type | Description |
|---|---|---|
channelPrefix? | | Key/channel prefix. "@g14o:events" |
client | | Redis client (node-redis or ioredis). |
expireAfterSecs? | | Optional TTL applied to stream keys after append. |
maxLength? | | Max stream length (MAXLEN ≈). |
UpstashStreamOptions
| Option | Type | Description |
|---|---|---|
channelPrefix? | | Key/channel prefix. "@g14o:events" |
expireAfterSecs? | | Optional TTL applied to stream keys after append. |
maxLength? | | Max stream length (MAXLEN). |
redis | | Upstash Redis REST client (or compatible). |
EventStream
Pluggable stream contract for custom backends (defineStream). See Streams for built-in adapters and Deployment for multi-instance wiring.
EventProviderProps
| Option | Type | Description |
|---|---|---|
api? | | SSE endpoint and fetch credentials. |
children | | |
maxReconnectAttempts? | | Max automatic reconnect attempts after disconnect. |
ProviderApiConfig
| Option | Type | Description |
|---|---|---|
url? | | SSE subscribe URL (default |
withCredentials? | | Send cookies on the EventSource request. |
UseEventOptions
Client hook options from createEvent().useEvent. The channels option scopes delivery — see Channel.
| Option | Type | Description |
|---|---|---|
channels? | | Channel names to subscribe to (undefined entries are ignored). |
enabled? | | When false, skip registering until enabled. |
events? | | Event names to receive; omit for all typed events. |
onData? | | Called for each matching realtime message. |
PipelineLogOptions
Options for createPipelineLog.
| Option | Type | Description |
|---|---|---|
formatEnd? | | Format a pipeline-end log line. |
formatStart? | | Format a pipeline-start log line. |
maxEntries? | | Max middleware log entries retained in memory. |
Package entry points
| Import | Description |
|---|---|
@g14o/events | Event, handler, strategies, errors, createPipelineLog, defineStream |
@g14o/events/client | EventProvider, createEvent, hooks |
@g14o/events/memory | memoryStream |
@g14o/events/redis | redisStream |
@g14o/events/upstash | upstashStream |