API Reference
Reference for the public API of the two published packages: @artstesh/postboy (the message bus, applies to v3.5.x) and @artstesh/postboy-testing (the BDD testing toolkit, applies to v3.4.x, peers @artstesh/postboy ^3.4.1). For the conceptual model behind these APIs, see Concepts and How it works.
What the public API covers
The public API is the user-facing layer of Postboy: a typed, structured way to work with event-driven communication without depending on internal mechanics. It includes:
The bus —
PostboyServicewith the verbsfire,fireCallback,sub,once,exec, anddispose.Messages —
PostboyMessage,PostboyGenericMessage(events),PostboyCallbackMessage<T>(request/response), andPostboyExecutor<T>(synchronous commands), plus their metadata types.Registration and lifecycle —
PostboyAbstractRegistrator,IPostboyDependingService, and the namespace machinery.Infrastructure messages —
Connect*,DisconnectMessage, lock/unlock, middleware, and namespace messages; the only way to mutate the bus since v3.5.Middleware — the staged pipeline:
PostboyMiddleware, stages, decisions, pipeline contexts, and cancellation types.The testing toolkit —
PostboyWorld, the recordingPostboyServiceMock, given/then/waiter services, message history, and the boolean verifier.
Design principles: typed first, framework-agnostic, message-driven (bus operations are messages too), extensible, and consistent across similar operations.
Reference map
Every part of the public API has a dedicated reference page:
Area | Page |
|---|---|
The bus — | |
Data carriers — | |
Lifecycle owners — | |
The pipeline contract — | |
Bus mutations — | |
The testing toolkit — |
Reading conventions
Named exports only. Neither package has a default export. Always import symbols by name from the package root; sub-paths are not part of the public surface.
Dual ESM/CJS build. Since v3.4 both packages ship a dual-format build:
lib/index.mjsfor ESM/TypeScript consumers andlib/index.cjsfor CommonJS, selected automatically by the packageexportsmap.
Routing is keyed by static
ID. Every message and executor class declares its own uniquestatic readonly ID; all bus lookups use that string, not class identity.Truth source. These pages are written against the installed versions. When in doubt, verify signatures in
node_modules/@artstesh/postboy/lib/index.d.ts(or the equivalent in@artstesh/postboy-testing).Deprecation policy. Methods marked deprecated still work in the 3.x line and are scheduled for removal in the next major line; each one lists its replacement. See Versions for the version lines and release notes.
Related topics
Installation — adding the packages to a project
Best practices and Caveats — how to use the API well
Migrating middleware from 3.4 — the v3.5 middleware changes