Using Common Code Across Services (Node JS)

When organizing Serverless Framework services, it seems like a common pattern to have groupings of lambda functions relevant to one specific domain (e.g. payments, underwriting, etc.). This naturally sets up a microservice-like architecture. What is the best way to create local util packages (i.e. rds-utils, processing-utils, etc.) such that each service can add one as a dependency? How do I ensure the package manager bundles the local packages with each service? The util packages would be in the same repository, and it would likely be the services directory and common directory are on equal levels.

Hi @johnjohnjohn

I’m not sure I can fully answer your question as I do not have experience with multiple services yet. I’m hoping to help you by referencing this article on multi-service deployments.

I also found this thread that will, hopefully, get you where you need to be :slight_smile:

My guess is that if you combine both ways of working, you’ll be able to package the shared libs and services in one go and be able to reference the shared libs across the services.

Good luck!

npm and yarn can link to projects on the local hard drive. You don’t have to publish the child project and then import/update it in the parent project. Just update the child project and your parent will automatically be up to date. Kodi