DEV Community

Discussion on: Bulletproof node.js project architecture 🛡️

 
dimpiax profile image
Dmytro Pylypenko

Yes, my idea to hide real response in a route is not a good idea.
Cause you have mixed flow.
In one case, you can put return in other res.SOMETHING, but not both.
It makes harder to maintain and avoid potential fails in a development team.

Thread Thread
 
victorzamfir profile image
Victor Zamfir

Yep, I see your point and you're right in a way.

I only use express.js to build APIs (I never render a template or something). So it's more like a convention (shortcut) as returing JSONs is what I do in 90% of the cases.

Thread Thread
 
dimpiax profile image
Dmytro Pylypenko

Yep, this is why I started from this message: "This code is probably for the specific use case, but looks not good."
For example, if you return await ... with undefined you will go in hang situation.