Connect-sequence

A node.js module to run connect-like middlewares in sequence

View project on GitHub

Classes

ConnectSequence

Typedefs

middlewareFilterBoolean

A middleware filter function run at the middleware runtime, causing the middleware or middleware list should be ran or skiped

ConnectSequence

Kind: global class

new ConnectSequence(req, res, next)

Param Type Description
req object The request object
res object The response object
next function The next middleware

connectSequence.run() ⇒ undefined

Run sequencially each appended middleware, using the next argument as the final callback.

Kind: instance method of [ConnectSequence](#ConnectSequence)

connectSequence.append(…middlewares) ⇒ [ConnectSequence](#ConnectSequence)

Append an arbitrary number of middlewares as an argument list

Kind: instance method of [ConnectSequence](#ConnectSequence)
Returns: [ConnectSequence](#ConnectSequence) - a reference to the instance to be chainable
Throws:

  • TypeError if one of the given middlewares is not a function. All the given middlewares would be rejected.
Param Type Description
…middlewares function A list of middleware functions (or errorHandler middlewares)

connectSequence.appendList(middlewares) ⇒ [ConnectSequence](#ConnectSequence)

Append an arbitrary number of middlewares as an array

Kind: instance method of [ConnectSequence](#ConnectSequence)
Returns: [ConnectSequence](#ConnectSequence) - a reference to the instance to be chainable

Param Type Description
middlewares Array.<function()> An array of middleware functions (or errorHandler middlewares)

connectSequence.appendIf(filter, …middlewares) ⇒ [ConnectSequence](#ConnectSequence)

Append an arbitrary number of middlewares as an argument list if the filter pass at runtime of the first middleware in the given list

Kind: instance method of [ConnectSequence](#ConnectSequence)
Returns: [ConnectSequence](#ConnectSequence) - a reference to the instance to be chainable

Param Type Description
filter function A filter function (returning a Boolean)
…middlewares function A list of middleware functions (or errorHandler middlewares)

connectSequence.appendListIf(filter, middlewares) ⇒ [ConnectSequence](#ConnectSequence)

Append an arbitrary number of middlewares as an array if the filter pass at runtime of the first middleware in the given list

Kind: instance method of [ConnectSequence](#ConnectSequence)
Returns: [ConnectSequence](#ConnectSequence) - a reference to the instance to be chainable

Param Type Description
filter [middlewareFilter](#middlewareFilter) A filter function on the req object
middlewares Array.<function()> An array of middleware functions (or errorHandler middlewares)

middlewareFilter ⇒ Boolean

A middleware filter function run at the middleware runtime, causing the middleware or middleware list should be ran or skiped

Kind: global typedef

Param Type Description
req IncomingMessage The express request object