Reading List is a small web application built with the MVC pattern using Express , EJS view engine, and Mongoose ODM to connect to a MongoDB instance hosted by MongoDB . It is hosted on AWS using an EC2 instance.
Setting up the Application
To set up the application:
Install node packages.
Set environment variables.
export MONGO_USER=<user_name>
export MONGO_PASSWORD=<password>
export MONGO_CLUSTER=<cluster>
export MONGO_DBNAME=<db_name>
export MONGO_USER_ID=<mongo_user_collection_id>
Copy from name down to create a user object as shown below.
NOTE: MONGO_USER_ID is from the custom user collection in the database.
You can access the database with MongoDB compass .
{
"_id": {
"$oid": "****"
},
"name": "user"
"email": "user@test.com",
"reading": {
"items": []
}
}
To start the application, run the following command:
This project uses Mocha and Chai for testing.
All Tests can be found in the test folder.
To test the application, run the following command.
NOTE: If the tests begin to timeout due to new tests being created, update the timeout value in the scripts test section in the package.json file.
Name
Description
admin
Handles the creation, updating, and deletion of books
book
Handles getting books
reading
Handles getting reading list and favorite genre
error
Handles all error events
Name
Description
book
Handles book data
user
Handles all user data and reading lists
Paths
Method
admin/add-book
POST
admin/edit-book/:bookId
POST
admin/delete-book
POST
Paths
Method
/
GET
/books
GET
/books/:bookId
GET
Paths
METHOD
/reading/list
GET/POST
/reading/favorite-genre
POST
/reading/favorite-data
POST
/reading/delete-item
POST
View
Description
/edit-books
Used to edit and create books
View
Description
book-details
Used to view books
index
Used to view list of books
View
Description
favorite
Used to view pie chart built with reading list
list
Used to view reading list
View
Description
add-to-reading
A button to inject into view to add books to reading list
end
End of HTML page
head
Top of HTML page
navigation
Navigation bar used in all views