I'm working on a nodejs app that will become larger. I don't find a lot of ressources for advanced Nodejs project architecture and structure. I would like to know if it's an antipattern to mix paradigm of promises with Events in NodeJS.
If someone have ressources about advanced project architecture or open source large Nodejs projects, it could really help me.
Best regards.
It is not wrong to mix Promises and callbacks. Sometimes it is necessary, especially if a library or existing code only has one or the other. Callbacks and Promises are just ways of handling the asynchronous nature of NodeJS, so just be aware of controlling the flow of your program.
Some other thoughts:
I find it easier to use Promises inside of callback functions, as you can use the Promise resolution to determine when and how to call the callback
If possible, promisify your callbacks (or even other callback libraries) if you can! That might be a personal preference of mine since I like promises more. Some libraries even allow you to go from Promises to callbacks, but I haven't done that.
The ES6 async/await stuff changes things again! So keep adapting as you are able, or as you need to.
There is nothing wrong with callbacks or Promises. No wrong choice and it's ok to mix, just keep control flow in mind.