Skip to content

Built-in Stamps

This page lists all the built-in Stamps that Missive.js provides. Stamps are a way to handle cross-cutting concerns in your application. They are key to keeping your code clean and maintainable. Most of all, they are easy to write and use, and they can be generic!

Added by the Bus

IdentityStamp

type AsyncStamp = Stamp<undefined, 'missive:async'>;

Added on bus.dispatch(intent|envelope).

HandledStamp

type HandledStamp<R> = Stamp<R, 'missive:handled'>;

Added when the intent is handled by the handler.

ReprocessedStamp

type ReprocessedStamp = Stamp<{ stamps: Stamp[] }, 'missive:reprocessed'>;

Added when an envelope is dispatched through the bus instead of an intent.

The bus will save the original stamps in the ReprocessedStamp stamp.

This happens with 2 built-in middlewares:

  • Using the Async middleware in a consumer, you will get a ReprocessedStamp because you should dispatch the envelope instead of the intent.
  • Using the Cacher middleware you will get a ReprocessedStamp because the middleware will redispatch the envelope to the queryBus for Stale While Revalidating purposes.

Added by the Middlewares

AsyncStamp

type AsyncStamp = Stamp<undefined, 'missive:async'>;

Added when the envelope is sent to a queue via the Async middleware.

FromCacheStamp

type FromCacheStamp = Stamp<{ age: number; stale: boolean }, 'missive:cache:hit'>;

Added when the Cacher middleware finds the result in the cache.

CacheableStamp

export type CacheableStamp = Stamp<{ ttl?: number; staleTtl?: number }, 'missive:cacheable'>;

That you can add in your handler to have cache on demand. See Cacher middleware.

FeatureFlagFallbackStamp

type FeatureFlagFallbackStamp = Stamp<undefined, 'missive:feature-flag-fallback'>;

When the Feature Flag Middleware uses a fallbackHandler.

TimingsStamp

type TimingsStamp = Stamp<{ total: number }, 'missive:timings'>

Add by the Logger middleware when the message is handled or errored with the total time elapsed in nanoseconds.

RetriedStamp

type RetriedStamp = Stamp<{ attempt: number; errorMessage: string }, 'missive:retried'>;

Added by the Retryer middleware when the middleware retries the handling of the intent.

WebhookCalledStamp

type WebhookCalledStamp = Stamp<{ attempt: number; text?: string, status?: number }, 'missive:webhook-called'>;

Add by the Webhook middleware when the middleware succeed to call the webhook(s) or ultimately at the end of the retries.


Missive.js. MIT License.
Powered by Astro Starlight.
Inspired by Symfony Messenger