ngneat / nx-serverless

🚀 The Ultimate Monorepo Starter for Node.js Serverless Applications
https://netbasal.com
MIT License
399 stars 26 forks source link

Dependency Injection? #14

Open stottle-uk opened 2 years ago

stottle-uk commented 2 years ago

Hi

Many thanks for putting this repo together, it is an excellent example.

What are your thoughts on using a Dependency Injection library like tsyringe? Could 'newing up' several dependencies in your todo service lead to a lot of boilerplate setup for each handler when more abstractions are created around IO and Business Logic?

I've forked your repo, created a branch and refactored the todo service with a few tests as a basic example - https://github.com/stottle-uk/nx-serverless/tree/dependency_injection.

Any thoughts or ideas you have would be much appreciated.

Kind regards

NetanelBasal commented 2 years ago

I didn't use DI and chose pure exported functions to benefit from tree-shaking. By doing so, each lambda bundles the minimum it needs.