Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
A while back, a client asked me “how can I share business logic between services in a Node.js monorepo?”. The TL;DR of it is:
- Encapsulate the shared business logic into modules, and put them in a separate folder.
- In the Lambda handler functions, reference the shared modules using relative paths.
- Use webpack to resolve and bundle them into the deployment package. If you use the Serverless framework, then check out the serverless-webpackplugin. For example:
- Deploy every service on every commit. You can do this with a simple script like the following.
To see how everything fits together, check out this demo repo. It has CI/CD set up already through drone.io and you can see a recent deployment of all the services in the monorepo here.
But wait! How do I choose between having a monorepo vs a repo per service?
Don’t worry, I’ve got you covered for that too ;-) You can read about my thoughts on the two approaches here.
Hi, my name is Yan Cui. I’m an AWS Serverless Hero and the author of Production-Ready Serverless. I have run production workload at scale in AWS for nearly 10 years and I have been an architect or principal engineer with a variety of industries ranging from banking, e-commerce, sports streaming to mobile gaming. I currently work as an independent consultant focused on AWS and serverless.
You can contact me via Email, Twitter and LinkedIn.
Check out my new course, Complete Guide to AWS Step Functions.
In this course, we’ll cover everything you need to know to use AWS Step Functions service effectively. Including basic concepts, HTTP and event triggers, activities, design patterns and best practices.
Get your copy here.
Come learn about operational BEST PRACTICES for AWS Lambda: CI/CD, testing & debugging functions locally, logging, monitoring, distributed tracing, canary deployments, config management, authentication & authorization, VPC, security, error handling, and more.
You can also get 40% off the face price with the code ytcui.
Get your copy here.
Originally published at https://theburningmonk.com on June 29, 2019.
AWS Lambda: how to share code in a monorepo was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.