Changing the application's structure
Let's make some changes to the structure of directories in our application and prepare it to follow the Model-View-Controller design pattern.
I will list the necessary steps for this refactoring:
- Inside the
root
project folder:- Create a new folder called
server
- Create a new folder called
- Inside the
server
folder:- Create a new folder called
config
- Create a new folder called
routes
- Create a new folder called
views
.
- Create a new folder called
- Do not worry about the
config
folder at this point; we will insert its contents later. - Now we need to move the
error.js
andindex.js
files from thechapter-01/views
folder to thechapter-01/server/views
folder. - Move the
index.js
anduser.js
files from thechapter-01/routes
folder to thechapter-01/server/routes
folder. - A very simple ...
Get Node.js 6.x Blueprints now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.