So i'm currently using the middy warmup middleware and had a .before() at the end. I'm just wondering what the order of execution is? does it go straight to the .before block or does it check if its warmed up first?
I'm new to all this so sorry if i'm not making sense hopefully this code helps.
const handler = middy(originalHandler)
.use(warmup())
.use(
cors({
origins: [fetchEnvironmentVariable('SOME_ENDPOINT')],
credentials: true
})
)
.use(requestMiddleware())
.before(async () => {
// some code
})
return handler()
Short answer:
before
always runs before the handler execution.Straight to before block.
From documentation
Nice example you can find here.