Katman
Plugins

Plugins

Extend Katman with CORS, distributed tracing, structured logging, rate limiting, and more.

Katman plugins are just regular middleware and hooks. There is no special plugin API — a "plugin" is a guard, a wrap, or a set of lifecycle hooks that someone has packaged up for reuse.

All plugins ship as subpath imports from the katman package. You only import what you use, and unused plugins add zero bytes to your bundle.

You can build your own plugins the same way. A guard that checks a feature flag, a wrap that logs slow queries, a set of hooks that track metrics — they all follow the same patterns described in the Middleware and Server docs.

Plugin types at a glance

PluginTypeHow to use
CORSHeader helperCall corsHeaders() to get a headers object
OpenTelemetryWrap middlewareAdd otelWrap(tracer) to a procedure's use array
Pino LoggingLifecycle hooksPass loggingHooks({ logger }) to the hooks option
Rate LimitingGuard middlewareAdd rateLimitGuard(...) to a procedure's use array
Body LimitGuard middlewareAdd bodyLimitGuard(...) to reject oversized payloads
Strict GETGuard (singleton)Add strictGetGuard to enforce GET on queries
CookiesHelper functionsUse getCookie(), setCookie(), deleteCookie()
CompressionWrap middlewareAdd compressionWrap() for gzip/deflate hints
SigningHelper functionsUse sign(), unsign(), encrypt(), decrypt()
Smart CoercionGuard (singleton)Add coerceGuard to auto-convert string inputs
Server BatchHandler factoryUse createBatchHandler() for batch endpoint
Publisher/PubSubEvent systemUse createPublisher() + MemoryPubSub or Redis
Custom SerializersHelperUse createSerializer() for custom JSON types

What's next?

  • Middleware — understand guards and wraps, which power most plugins
  • Server — lifecycle hooks, which power the logging plugin

On this page