chrisbug / readinglist

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

READING LIST

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.

alt text

Setting up the Application

To set up the application:

  1. Install node packages.
npm install
  1. 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>
  1. 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": []
  }
}
  1. To start the application, run the following command:
npm start

Testing the Application

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.

npm test

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.

Controllers

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

Models

Name Description
book Handles book data
user Handles all user data and reading lists

Routes

admin

Paths Method
admin/add-book POST
admin/edit-book/:bookId POST
admin/delete-book POST

book

Paths Method
/ GET
/books GET
/books/:bookId GET

reading

Paths METHOD
/reading/list GET/POST
/reading/favorite-genre POST
/reading/favorite-data POST
/reading/delete-item POST

Views

admin

View Description
/edit-books Used to edit and create books

book

View Description
book-details Used to view books
index Used to view list of books

reading

View Description
favorite Used to view pie chart built with reading list
list Used to view reading list

includes

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

About


Languages

Language:JavaScript 52.8%Language:EJS 33.8%Language:CSS 13.4%