Online bookstore web app with REST API.
- Install the dependencies (packages):
npm install
- Create
.env
file and paste thePORT
andMONGO_URI
(from Google Drive) - Run
npm run start
to initialize the server.
They are saved in the Team Google Drive. Keep in mind the .DOTENV setup
Note: if the Database doesn't seem to be responding, that may indicate the
.env
or credentials aren't valid
- Database: MongoDB (Atlas) through Mongoose
- Backend: Node.js/Express.js
- Client: Postman
Given a specific genre, return a list of books for that genre.
- Method: GET
- Endpoint:
/browser/books/genre/:genre
- Body:
empty
- Responses:
- 200 (success): JSON object containing the book with that genre info
- 404 (failure): there were no books with that genre
Return the top 10 books that have sold the most copies in descending order (most copies sold would be #1)
- Method: GET
- Endpoint:
/browser/books/top10
- Body:
empty
- Responses:
- 200 (success): JSON object containing the top 10 books (by copiesSold) in descending order
Filter by rating higher or equal to the passed rating value.
- Method: GET
- Endpoint:
browser/books/rating/:rating
- Body:
empty
- Responses:
- 200 (success): JSON object containing the top 10 books (by copiesSold) in descending order
Update the price of all books under a publisher by a discount percent
-
Method: PUT
-
Endpoint:
browser/books/rating/:rating
-
Body: JSON object containing
percentDiscount
andpublisher
Note:
percentDiscount
is expressed as a PERCENTAGE. So 20 -> indicates 20% discount{ "percentDiscount": "20", "publisher": "Warner Books" }
-
Responses:
- 202 (success): Successful update message
Provided the user fields, create the user in the database
- Method: POST
- Endpoint:
users/create
- Body: JSON object containing required user fields
username
,password
andpasswordConfirm
, as well as optional fieldsname
, emailAddress,
homeAddress,
creditCards,
wishListand
shoppingCart` - Responses:
- **200 (user added): JSON object containing user details for current user created
Given a specific username, retrieve the user details
- Method: GET
- Endpoint:
users/username/:username
- Body:
empty
- Responses:
- **200: JSON object containing user details for requested user
- **400 (user not found): There is no user for the queried username
Given the username as a key lookup valueand any other user fields, update that user field with the new parameter value
- Method: PUT
- Enpoint:
users/updateuser/:username
- Body: JSON object containing user fields to be updated
- Responses:
- **200: JSON containing updated user fields
- **404 (ERROR): There is no user for the the queried username
Given a user name and credit card details, create a credit card for that user
- Method: POST
- Endpoint:
users/creditcards/:username
- Body: JSON object containing
creditCardNumber
,securityCode
andexpiryDate
- responses:
- **200: JSON object containing user details and creditCard fields populated
- **404 (ERROR): There is no user for the the queried username
Get the sum price of all books in shopping cart
- Method: GET
- Endpoint:
/shoppingCart/:username/total
- Body:
empty
- Responses:
- 200 (success): Shopping Cart Subtotal: (Subtotal)
- 404 (failure): Error Message
Adds an isbn number to the shopping cart array of a user
- Method: POST
- Endpoint:
/shoppingCart/:username/add/:ISBN
- Body:
empty
- Responses:
- 200 (success): Book (ISBN) added to shopping cart
- 404 (failure): No such ISBN: (ISBN)
Get a list of all the books that correspond to the ISBN numbers inside the shopping cart of a user
- Method: GET
- Endpoint:
/shoppingCart/:username/list
- Body:
empty
- Responses:
- 200 (success): JSON object containing all books corresponding to ISBN numbers in shopping cart
- 404 (failure): Error Message
Remove a specific isbn number from the users shopping cart.
-
Method: DELETE
-
Endpoint:
/shoppingCart/:username/remove/:ISBN
-
Body:
empty
-
Responses:
- 200 (success): Book (ISBN) removed from shopping cart
- 404 (failure): No such ISBN: (ISBN)
name, book description, price, author, genre, publisher , year published and copies sold
Create a book with the provided information including the book ISBN, book name, book description, price, author, genre, publisher , year published and copies sold.
- Method: POST
- Endpoint:
/books/createBook
- Body: JSON object containing
title
,ISBN
,author
,genre
,copiesSold
,rating
,publisher
,price
,description
,yearPublished
,rating
andcomments
- Responses:
- 200 (success): Book Added! message
- 404 (failure): Error Message
Return the book details associated with the provided ISBN number
- Method: GET
- Endpoint:
/books/ISBN/:ISBN
- Body:
empty
- Responses:
- 200 (success): JSON object containing the books information from the provided ISBN
- 404 (failure): Error Message
name, biography and publisher
Create an author with the provided information including first name, last name, biography and publisher
- Method: POST
- Endpoint:
books/createAuthor
- Body: JSON object containing
firstname
,lastname
,biography
,publisher
- Responses:
- 200 (success): Author added! message
- 404 (failure): Error Message
Given an authors name, return a list of books associated with that author.
-
Method: GET
-
Endpoint:
books/author/:author
-
Body:
empty
-
Responses:
- 200 (success): JSON object containing the books associated with the provided author
- 404 (failure): Error Message