Skip to content

Connectum API Reference / @connectum/events / composeMiddleware

Function: composeMiddleware() ​

composeMiddleware(middlewares, handler): (event, ctx) => Promise<void>

Defined in: packages/events/src/middleware.ts:24

Compose an array of middleware into a single handler.

Middleware is applied from left to right (outer to inner). The innermost function is the actual event handler.

Uses a dispatch pattern that guards against double next() invocation.

Parameters ​

middlewares ​

EventMiddleware[]

Middleware functions to compose

handler ​

(event, ctx) => Promise<void>

The final handler (innermost)

Returns ​

Composed handler function

(event, ctx) => Promise<void>