Skip to content

Primitives

Every public define* / create* primitive, grouped by what it's for. Summaries come straight from each symbol's doc comment, so this page can't drift from the shipped surface. Each links to its full reference page.

App & transport

Build an app, wire handlers, mount it under an endpoint.

PrimitivePackageWhat it does
createApp@nwire/appCreate an app — the container, plugins, and handlers that make up a backend.
appCompose@nwire/appCompose several apps into one process; each keeps its own container.
createTestApp@nwire/test-kitBoot an app in-process with in-memory adapters, for tests.
definePlugin@nwire/appPackage cross-cutting behaviour: container bindings, lifecycle hooks, boot/shutdown work.
defineCapability@nwire/runtimeDeclare a typed capability that locks a ctx contribution into the type system and the runtime.

Handlers, errors & responses

The transport-agnostic unit of work and the surface it presents.

PrimitivePackageWhat it does
defineHandler@nwire/handlerDefine a named handler — the transport-agnostic unit of work.
defineResource@nwire/handlerDeclare the public shape of a response; the field allow-list is the contract.
defineError@nwire/handlerDeclare a typed, status-tagged error to throw; the transport renders it safely.

Events & reactions

Announce facts and react to them.

PrimitivePackageWhat it does
defineEvent@nwire/messagesDeclare a past-tense fact with a schema — emitted by handlers, reacted to by listeners.
defineAction@nwire/forgeDeclare a command: a named, typed intent a handler fulfils and may emit events from.
defineCommand@nwire/messagesDeclare a typed command message (name + input schema).

Forge — state & read models

The opt-in battery for things that hold state and views you query.

PrimitivePackageWhat it does
defineActor@nwire/forgeModel a thing with identity that owns its state and enforces a rule.
defineSchema@nwire/forgeDeclare an actor's data shape, key, and lifecycle states, once.
defineProjection@nwire/forgeFold events into a read model shaped for how it's queried.
defineQuery@nwire/forgeDeclare a typed read over a projection.
defineWorkflow@nwire/forgeReact to events over time: a stateless reaction or a stateful saga with timers.

Orchestrator — scheduled & external work

Cron, inbox/outbox, webhooks, and outbound calls.

PrimitivePackageWhat it does
defineCron@nwire/forgeRun a handler on a schedule.
defineInbox@nwire/forgeDeduplicate and record inbound messages for idempotent processing.
defineOutbox@nwire/forgeBuffer outbound events for reliable delivery.
defineExternalCall@nwire/forgeWrap a call to another system with retries and telemetry.
defineInboundWebhook@nwire/forgeTurn an inbound HTTP webhook into a typed dispatch.

Access control

Permissions and policy.

PrimitivePackageWhat it does
defineAbility@nwire/rbacDefine an ability factory — a pure function from a user to a CASL ability.

Other

PrimitivePackageWhat it does
createAppHooks@nwire/appConstruct a per-App lifecycle registry with every built-in slot pre-instantiated.
createMongoActorStore@nwire/mongoA MongoDB-backed actor store (collections + lock) from one Db.
createPinoLogger@nwire/logger-pinoA Logger backed by pino with sensible defaults.
defineEnv@nwire/configDeclare the app's environment contract from a zod schema.
defineRegistry@nwire/appDeclare an app registry by hand.

27 primitives.

MIT licensed.