• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

React,Express,Node: Where goes where (especially the business logic)

 
Ranch Hand
Posts: 2102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Front end:  I think react should be isolated to front end stuff, like getting input, displaying output, making the ui easy to use.  This should not have business logic that are confidential or security-related stuff.

Express:  I really not sure, but this sounds like counter-part of Spring Controllers.  So I am thinking of able to put some logic here, but heavy business logic, especially those related to reusable services like talking to databases, will be isolated in Node modules (simple separated javascript files, maybe 1 javascript file per service, e.g. 1 for LoginService, 1 for CustomerService, etc.).

Node:  simply there to run the Express, and support the javascript modules (which would run on node, and called by Express controllers)


React <--> Express controllers <--> Node services

I have been looking at where to put the business logic, but can see definitive answers in web.  Probably there isnt.  But what are the best practices, and possibly any framework out there to 'force' us to do a better separation of these concerns?  

I will greatly appreciate your sharing of your knowledge.

Regards,
Jesus
 
Bartender
Posts: 20842
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not familiar with React, although I have a client using it, so will probably get more familiar in the future.

I do use Express for quick-and-dirty projects though. My more extensive projects use Java, of course.

In my case, most of the business logic is done in the routes files. I have one script that does things outside of web requests and for better or worse, I simply put it in the project root directory alongside app.js.

For a more rigorous app, the likely place to put business modules seems to be the bin directory, although even better would be to create it as a module and put it in the node_modules directory, I think.

People with more expertise in Node could give better answers, but this works for me.
 
Jesus Angeles
Ranch Hand
Posts: 2102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:....



I am also coming from a Java background.

We have everything like Spring and Hibernate to help us in development and having cleaner separation of concerns.  I am sure that such will come to the Node world too; actually it could be there already, I just dont know which or what they are.  It is a relatively young world.
 
Jesus Angeles
Ranch Hand
Posts: 2102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyone?
 
Tim Holloway
Bartender
Posts: 20842
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Node definitely supports modules. Even a very simple Express app that I have is absolutely enormous because it has lots of modules supporting it. I'm sure that there's at least one good tutorial on how to design a Node module.
 
Jesus Angeles
Ranch Hand
Posts: 2102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:Node definitely supports modules. Even a very simple Express app that I have is absolutely enormous because it has lots of modules supporting it. I'm sure that there's at least one good tutorial on how to design a Node module.



Yes, it looks like it will be modules (e.g. 1 file per service, which is taken as a module), either by TypeScript or javascript modules.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!