Friday, 1 December 2017

Need help with structuring my node app (conceptual)

I’m fairly new to Node development, coming from a PHP background. I have a few basic questions about how to best structure my upcoming project.First I want to serve a simple web server. That’s no problem via Express and I’ve already got the up and running. It serves a simple site to users and connects to a MongoDB for some data.Now the tricky part. I need another script that connects via web sockets to a third party constantly updates the same MongoDB when some specific event occurs. Again I think this is easy on it’s own, but working together with my web server app I’m a little confused. Should I decouple these and have them both running as separate scripts under pm2?Finally, to complicate things. I need a third script that every x seconds needs to manually load data from a different third party and also update some data in the same MongoDB. In my old stack, I’d use something like a CRON job for this. But I’m clueless when it comes to Node. Do I have this again as a third script completely separate from the first two? I’ve seen a few CRON-like packages for node, but not entirely sure how they work under the hood, do they run one script continuously to monitor all the registered Cron tasks?How would you guys approach this project? Three separate scripts (each with their own DB connection) or somehow a shared single script that delegates to some sort of sub-module for each of these 3 tasks. Is this what microservices are all about (I have a very poor understanding of what these are)?Thanks!

Submitted December 01, 2017 at 08:24PM by zeldaze

No comments:

Post a Comment