*We decided to share our development standards and best practices with the community in the spirit of transparency and to help other teams just getting started in the serverless space. Have suggestions, questions or just want to say ‘hi’? we’d love to hear from you!
Find us on Twitter at @Produce8HQ or check us out at www.produce8.com.*
Lambdas are a very powerful technology. A nearly unlimited amount of processing power and nearly endless set of integrations are available to the developer, and scalability and hosting become afterthoughts. You can choose from a long list of supported languages like Go, C#, Python or Nodejs and you can get started for free!
But with great power comes some tradeoffs, such as the lack of a supporting web framework that developers might be accustomed to (ie. MVC) and some additional AWS-specific concepts that can trip you up.
While it’s easy to get started, if you don’t have a plan for testing, code re-use and an overall architectural approach that works, you’ll quickly find yourself with a lot of spaghetti code that’s hard to maintain.
At Produce8, we’ve developed some tools and standards that will help you get the most out of your lambdas while keeping your code clean and easily supported. We wanted to follow the SOLID principles for all Lambdas and encourage testability and DRY.
All the code samples are in Typescript, but the concepts should apply to any of the supported runtimes.
Read on for deep dives and code samples!
Dependency Injection is a commonly used pattern in modern applications that allows you to decouple the components of your application. Without it, writing reliable unit tests is nearly impossible. We use the Awilix framework to create a Container that all lambdas can access.