MVC
MVC pattern is a solution proposed to solve the problem that code increases in application development and becomes difficult to maintain and reuse. Model is a Model, which contains data structure and logic related to data structure, such as user management, state change and maintenance, etc. A View is a View that is presented to the user (broadly, the client) based on data from one or more models. A Controller is a Controller that receives requests from the user. Manipulate or extract the model and render it to the View
Express the MVC
In Express, we can create the following structure:
routes/
views/
models/
services/
public/Copy the code
Where, due to express features, according to the Settings, The file in the views directory is automatically rendered by the template engine when res.render(‘view_name’) is called. The view layer is interpreted as the template engine + the file in the views folder. The model and the related logic services are somewhat special. Due to the need for decoupling between the models at the same level, a single model should not contain too many operations on other models. We should unify a set of logically related models within services.
Public is used to store public static resources.