What is the ideal file / directory structure for Node.js MVC?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



What is the ideal file / directory structure for Node.js MVC?



Most Node examples and tutorials suggest setting up directories for Model, Views and Controllers and an "app.js" as a main file of the app. It seems a bit messy, since the app.js insn't really any of the MVC trio. It is actually quite a good candidate to be a controller, which works with the model and view modules.


So: Is it rule or convention breaker to go ahead with a M+V+app.js scenario, in case not more then one controller module is needed?




1 Answer
1



The ideal file structure for your node application is the structure that best fits your needs. There is no absolute rule about how to structure your app.



MVC is a generic template to structure your application, which you are free to use, or not.



By convention, the root file of your node application is an app.js or an index.js file.



If your application logic is simple enough that you to do not need to put your controllers files in a separate directory, you can stay with your app.js file alone.
That will not break the MVC paradigm as MVC is a pattern, not a directory structure.





Thanks, I kinda thought this was going to be the answer. You say MVC is paradigm, not structure, but it has to manifest in code, though. So, "when does MVC cease to be MVC?" should probably have been a better question?
– Marko36
Aug 11 at 8:47






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard