business logic Focus on business logic Scalability Scalability Pay-per-use model (compute time * memory) Pay-per-use model (compute time * memory) Forces you to think micro-services Forces you to think micro-services @loige loige.link/middy-gcs-qa 5
weekly newsletter ( ) A middleware framework for AWS Lambda ( ) Enterprise Trading, Billing engine, Market data aggregator solutions ( ) Big data pipeline to make network metadata searchable ( ) Organised various workshops around Europe ( ) Fullstack bulletin middy.js.org ESB Vectra.ai Serverlesslab.com @loige loige.link/middy-gcs-qa 6
Serverless is more than just FaaS ... but here we will focus mostly on AWS Lamda ... but here we will focus mostly on AWS Lamda @loige loige.link/middy-gcs-qa 7
get input from event and context // return output or throw an error } Anatomy of a Node.js lambda on AWS Anatomy of a Node.js lambda on AWS @loige loige.link/middy-gcs-qa 9
variables with KMS // deserialize the content of the event // validate input, authentication, authorization // REAL BUSINESS LOGIC // (process input, generate output) // validate output // serialize response // handle errors } Real World Real World vs vs Hello World Hello World @loige loige.link/middy-gcs-qa 11
variables with KMS // deserialize the content of the event // validate input, authentication, authorization // REAL BUSINESS LOGIC // (process input, generate output) // validate output // serialize response // handle errors } Real World Real World vs vs Hello World Hello World @loige loige.link/middy-gcs-qa 11
variables with KMS // deserialize the content of the event // validate input, authentication, authorization // REAL BUSINESS LOGIC // (process input, generate output) // validate output // serialize response // handle errors } Real World Real World vs vs Hello World Hello World @loige loige.link/middy-gcs-qa 11
variables with KMS // deserialize the content of the event // validate input, authentication, authorization // REAL BUSINESS LOGIC // (process input, generate output) // validate output // serialize response // handle errors } Real World Real World vs vs Hello World Hello World LOTS of BOILERPLATE @loige loige.link/middy-gcs-qa 11
a real project with many lambdas, we might end up with a lot of code duplication! we might end up with a lot of code duplication! @loige loige.link/middy-gcs-qa 12
Can we avoid a bit of clutter by separating "pure pure business logic business logic" from the " " from the "boilerplate boilerplate"? "? @loige loige.link/middy-gcs-qa 13
stopped First middleware implementing `onError` gets control It can choose to handle the error, or delegate it to the next handler If the error is handler a response is returned If the error is not handled the execution fails reporting the unhandled error @loige loige.link/middy-gcs-qa 23
= middy((event, context, callback) => { // do stuff }) handler.before((handler, next) => { // do something in the before phase next() }) handler.after((handler, next) => { // do something in the after phase next() }) handler.onError((handler, next) => { // do something in the on error phase next() }) module.exports = { handler } @loige @loige loige.link/middy-gcs-qa 25
to build apps quickly and with a greater focus on business logic, rather than on infrastructure! Middy helps you to keep focusing on your business logic first You can add extra behaviours with very minimal changes to your core logic by introducing dedicated middlewares You can easily share common functionality through middlewares @loige loige.link/middy-gcs-qa 26
Use it Give feedback: Give feedback: Contribute (I am looking for co-maintainers) Contribute (I am looking for co-maintainers) Version 1.0 (stable) coming soon Version 1.0 (stable) coming soon github.com/middyjs/middy/issues github.com/middyjs/middy/issues @loige loige.link/middy-gcs-qa 27