AWS Senior Solutions Architect Sara Gerion announced on January 5, 2022 that Lambda Powertools TypeScript had entered public beta. Lambda Powertool...
For further actions, you may consider blocking this person and/or reporting abuse
Really nice write-up, Matt!
Hi @elthrasher,
Nice article, I was looking forward to exploring the lambda powertools and This article is a good starting point.
lambda powertools is great at providing best practices around observability and will be helpful for developers. Really helpful stuff.
Hi Matt,
I work on this project. Thanks a lot for reviewing the tool :) This is very valuable for us. We have been pushing ourselves to publish beta version to get a feedback like this so we could reiterate on the right path.
Totally agree on the point that decorator doesn't work on functions. Making functions into a class just to use the decorator feature really bugs me. This led to Middy support as an alternative. We (maintainers) are also concerned if it's commonly used enough. So we ended up supporting all 3 options.
Hey ijemmy, thanks for reading! I think you all made the right choice in supporting all three methods. I've been a middy user for years and I like what it provides, but have always disliked the API (while understanding why they made it that way). I'll probably stick with decorators and see how that goes, but you'll need the other methods anyway to support users who don't want to use transpilers.
Anyway, enjoy the positive feedback! Your team did a great job on this in spite of limitations in the language!
Classes without state, decorators, ... it's feels like a great option for folks who miss java in early 2000s
I don't miss the build times.
hey, @matt, maybe my point wasn't clear; what I meant is that I don't miss using stateless classes as namespaces for static methods and neither do I miss introducing magic on the codebase with anotations; I see these as bad practices on TypeScript codebases and I prefer to avoid them as much as I can and keeping the codebase clean and readable.
I can appreciate that perspective. I like using decorators (and I liked annotations in Java) because they reduce boilerplate code. There are definitely pros and cons and one thing to consider is the developers and teams that will need to interact with the code.
I've used decorators in express apps for years and I'm a big fan of putting something like
@Authorized
on a route instead ofif(!sessionNotValid(req)) throw Error(401)
or something like that. Remains to be seen whether I'll like using decorators in Lambda as much, but I can think of a lot more boilerplate that could be rolled up....In Node applications, I don't use decorators and neither do I use
if ...
statements to check for authorization inside handlers -- that's what's the middlewares are for...Nevertheless, at the end of the day, it's a matter of preference. Just keep in mind that support for decorators in typescript is not stable and you might have your build pipeline constrained to the tools that support it and you may encounter some issues when upgrading tsc compiler, for example.
Well... this solution was designed by someone who has never heard a word "Patterns", just spray syntactic sugar everywhere indiscriminately to solve all your problem.
Could have just used a decorator pattern, would have been backwards compatible with JavaScript, work with any kind of function, need no classes and actually be more compact than the code above...
sorry, I'm a bit annoyed in case you can't tell, but seriously we couldn't just do something like this?
What you want is supported using middy. You can use class decorators, middy-style function "decorators", or inline imperative statements. Check the docs and you'll see each example has a "Middy Middleware" example.
At least one of the DX improvements have been made :)
twitter.com/dreamorosi/status/1486...