Thursday 20 June 2019

"Separating UI from Service Logic" in Node

Hi Guys,I am new to Node and Web Dev in general. At work (IT dpt of a manufacturer) I am responsible for developing a prototype of a web application that we want to offer to our other departments. We have now started the conversation of what we would need to change or add to make it production ready.One of the guys (he's been in IT for a long time but I don't think he has done much in Web Dev or with Node for that matter) had a quick glance at my project structure and said "You are mixing UI with service logic, and will need a separate web server between the browser and the Node.js server".I am really struggling to understand this and when I asked if he could elaborate he just started to use some terminology I am not familiar with and mentioned that having the app server serving the views would be the standard of 2005.The basic architecture of my app looks like this:Express as Web Framework that handles requests and routesejs as my view / template enginemongoose for DB queries to the underlying Mongo DBFor Front-End I use vanilla JS and very little CSS as I am leveraging Materialize CSSThe App has in theory a very simple scope (the bigger challenge will be to get the correct data from our ERP system) and consists of a handful routes and views. I was able to cover all the UI elements in plain HTML (i.e. ejs) and as such I did not find it necessary to use (and learn in my case) a heavy weight frontend framework like Angular or React.With all this information provided, can you guys help me understand what those statements could mean and more importantly if I am following a bad practice with this architecture?My understanding of Express and view engines like pug or ejs was that they exactly do what that other guy is saying that I should not do: getting requests from the client, doing some DB queries or calling services from our ERP and serving the corresponding views based on the response.The reason I ended up learning and using node for this project to begin with was that after some research I found out that node seems to very good for handling exactly our use case due to its asynchronous and non-blocking nature: be able to handle requests that require you to do something "in between" (ie DB queries or service calls to ERP) whilst not blocking additional client requests.After that conversation I am now starting to doubt if I missed a critical part in my learning and developing journey so far and would like to get your opinions about those statements and my understanding of node.Hope my issue is somewhat understandable. Any input is much appreciated.Thanks

Submitted June 20, 2019 at 08:38AM by mayjay89

No comments:

Post a Comment