Project Directory Structure

The project is organized into the following directory structure:

Image ./: Contains the base application files and supporting folders. This is the project root.

Image ../node_modules: Created when the NPMs listed above are installed in the system.

Image ./controllers: Contains the Express route controllers that provide the interaction between routes and changes to the MongoDB database.

Image ./models: Contains the Mongoose model definitions for objects in the database.

Image ./static: Contains any static files that need to be sent, such as CSS and AngularJS code.

Image ./views: Contains the HTML templates that will be rendered by EJS.

This is just one method of organizing your code. You do not have to follow this directory structure, but keep in mind that directory structure should be part of the overall design of your projects so that you can easily find the code you are looking for.

In addition to the directory structure, the following code files are included. The following list is intended to give you an idea of the functionality of each file:

Image ./auth_server.js: Loads the necessary libraries, creates a connection to MongoDB, and starts the Express server. This is the main application file.

Image ./routes.js: Defines the routes for the Express server. This file handles functionality that does not apply to the database.

Image ./controllers/users_controller.js: Defines the functionality for the routes that require interaction with the MongoDB database model, including adding, retrieving, and deleting user objects.

Image ./models/users_model.js: Defines the user object model.

Image ./views/index.html: Provides the main page for the application, with links to edit the user or log out.

Image ./views/login.html: Provides the login page that authenticates the user.

Image ./views/signup.html: Provides a signup form that allows new users to create profiles.

Image ./views/user.html: Provides a form for editing a user profile.

Image ./static/js/my_app.js: Provides the AngularJS module and controller definitions to support AngularJS code in the view files already mentioned.

Image ./static/css/styles.css: Provides the CSS styling for the AngularJS HTML pages.

Image ../lib: A folder that contains the necessary AngularJS library files used in this example. This folder is a peer to the chapter folder in the book’s code archive.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.239.155