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:

  1. Inside the root project folder:
    • Create a new folder called server
  2. Inside the server folder:
    •  Create a new folder called config
    •  Create a new folder called routes
    • Create a new folder called views.
  3. Do not worry about the config folder at this point; we will insert its contents later.
  4. Now we need to move the error.js and index.js files from the chapter-01/views folder to the chapter-01/server/views folder.
  5. Move the index.js and user.js files from the chapter-01/routes folder to the chapter-01/server/routes folder.
  6. 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.