Originally posted at michaelzanggl.com. Subscribe to my newsletter to never miss out on new content.
Today we will take a look at controllers an...
For further actions, you may consider blocking this person and/or reporting abuse
What about module.exports = new ArticleService() instead of calling it on constructor?
Really great article. Thanks! :)
Then you would always get the same instance of ArticleService. In this case it would maybe not be a problem, but it would be inconsistent with the rest of the application I'd assume. But you are definitely right that it was not the best decision to simply new it up in the constructor. A better way would be to use Adonis' automatic dependency injection so it gets newed up automatically and is easy to fake.
Interesting article. When will the Post Controller refactoring come out ?
Thanks, I've just starting writing the module for it.