Middleware

Description

Middleware runs sequentially down the tree. It allows you to attach state or perform actions within a CommandLike

Example

const loggerMiddleware = async (context, next) => {
  const result = await next()

  console.log(`Middleware returned ${result}`)
}

const nextMiddleware = (context) => {
  return context.content.toUpperCase()
}

// Input: "This is a message."
// Output: "Middleware returned THIS IS A MESSAGE."

Generics

S
State
M
Message
C
Client
R
Response
Middleware
Middleware