使用middy warm up中间件时的执行顺序是什么?

What is the excution order when using the middy warmup middleware?

所以我目前正在使用 middy warmup 中间件,最后有一个 .before() 。我只是想知道执行顺序是什么?它是直接进入 .before 块还是先检查它是否预热?

我是新手,所以很抱歉,如果我没有理解,希望这段代码能有所帮助。

const handler = middy(originalHandler)
      .use(warmup())
      .use(
        cors({
          origins: [fetchEnvironmentVariable('SOME_ENDPOINT')],
          credentials: true
        })
      )
      .use(requestMiddleware())
      .before(async () => {
        // some code
      })

    return handler()

简短回答:before 始终在处理程序执行之前运行。

does it go straight to the .before block or does it check if its warmed up first?

直接到块前。

来自documentation

The before phase, happens before the handler is executed. In this code the response is not created yet, so you will have access only to the request.

你可以找到很好的例子 here