-
-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: self-composing UseFN #883
Conversation
@willfarrell Should it be 3.0 or 4.0? Also some old plugins add something to lambda context, while others add to events. I am kinda leaning towards extending the event object, so I intentionally left |
v4 is on hold till we know what AWS is going to do for their next runtime update (v18). That could be as early as Sept, or a year from now. I'm open to minor changes for v3 for now. There can also be a separate PR for v4, to allow others to comment. Changes to the event are the most common use in middlewares, however non-external inputs (ie secrets, db connections, etc) should live in the context. I personally don't use TS, so it's up to the community to decide what is best for Middy. This PR looks safe fro v3. |
My team is currently adding everything to event, including But I want this PR to be generally aligned with your advertised usage, I'll update it again to have |
380d1d4
to
2b39e42
Compare
@willfarrell It's ready now. Tried avoiding the necessity of Usage example in the description is updated to reflect the change. |
We may update the types in all packages, shall I do that here or in a new PR? For example, export const handler = middy()
.use(cloudwatchMetrics())
.handler(({}, { metrics }) => {
// The `metrics` property and its methods will be discoverable by IDEs
}); |
Within this PR is fine. |
@willfarrell added types for middlewares, please comment. |
TypeScript has no way to perform string matching without introducing unused vars, I have to skip these errors. Lines 10 to 11 in bd4badd
Lines 18 to 19 in bd4badd
|
Took another look at SSM and noticed a mistype, fixed it. Sidenote:
|
bd4badd
to
b820d4e
Compare
Rebased |
Looks good to me. I'm going to leave it open in case other would like to comment. I can merge and release next week. Thanks for all of the hard work putting this together. |
In respond to #769 (comment), this is the first attempt to make the event object self- and auto- composing through the chain of
.use()
.Intended usage: