-
Notifications
You must be signed in to change notification settings - Fork 176
Description
Summary
Currently the Middleware
type for middleware functions describes a function with three parameters: params
, options
, next
.
Since the function uses positional arguments, if I only want to use some of them I need to alias them to various combinations of _
(underscore) or linters might complain that the parameter is unused.
This is particularly apparent in middleware functions like the one below (from our docs) that only need to use next
, which appears as last argument:
const loggingMiddleware: Middleware = async (_, __, next) => {
logger.info('Request processed');
await next();
};
I wonder if we can change the signature to instead have an object, so that customers can pick only the parameters they want from it, like:
const loggingMiddleware: Middleware = async ({ next }) => {
logger.info('Request processed');
await next();
};
Will this cause the same issues described in the destructuring pitfalls section of the docs?
Why is this needed?
So that middleware functions have less boilerplate in the signature in most cases.
Which area does this relate to?
Event Handler
Solution
No response
Acknowledgment
- This request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status