Reputation: 1496
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?
Upvotes: 1
Views: 869
Reputation: 5931
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.
Upvotes: 1