📄️ Custom Middlewares
A middleware is an object that should contain at least 1 of 3 possible keys:
📄️ Configurable Middlewares
In order to make middlewares configurable, they are generally exported as a function that accepts
📄️ Inline Middlewares
Sometimes you want to create handlers that serve a very small need and that are not
📄️ Internal Storage
The handler also contains an internal object that can be used to store values securely between middlewares that
📄️ Handle Timeouts
When a lambda times out it throws an error that cannot be caught by middy. To work around this middy maintains an AbortController that can be signalled early to allow time to clean up and log the error properly.
📄️ More Examples
Check the code for existing middlewares to see more examples on how to write a middleware.
📄️ With TypeScript
here's an example of how you can write a custom middleware for a Lambda receiving events from API Gateway: