Hello,
I'm coming from a Ruby on Rails MVC background to Nest.js and the introduction of Dependency Injection and Services is making it difficult for me to architect a pretty simple solution where a webhook endpoint takes a type and id , then looks up the corresponding document from a CMS API, and then formats and saves the document to an ElasticSearch Index corresponding with the type.
Normally in Rails I would have the Model be responsible for the logic of persisting itself to the datastore, and use static aka class properties to represent concepts like overall indexName and how to indexAll documents. But with Nest.js it seems like I need to move almost everything into like SearchDocumentTypeAService and SeachDocumentTypeBService (and overcome duplication with mixins or something) and tell them about SearchIndexTypeAService and SearchIndexTypeBService. I think I could live with that but I'm not sure how to Inject the proper Service based on the type paramater from my requests?? This all feels way harder than it should be. Does anyone have examples/patterns/suggestions/advice for how to do this in Nest?? Much appreciated 🙏