Enviornment Variables:
- DATABASE_URL : connection string for MongoDB
- JWT_SECRET_TOKEN : some random bytes for creating JWT token for authentication
User Modules:
- Signup:
- url : /users/signup (POST)
- body {name,email,password} (user with email should not exist already)
- return created user
- Signin:
- url : /users/signin (POST)
- body {email, password}
- set cookies for further authtication and return the jwt token
** To access all below endpoints user should be logged in
Auth Middle ware:
- it check user is loggedin or not
- it also add user to req and user details from req are used by next funtions
Book Modules:
-
Create Book:
- url : /books/ (POST)
- body {barcode,title,author,genre,price}
- it default set quantity to 0
- return the created book
-
Get all books:
-
Get book by barcode:
- url : /books/:barcode (GET)
-
Update book by barcode (POST)
- url : /books/update/:barcode
- body {title, author, genre, price}
-
Enter book into store ( new books come into intentory so increase their quantity)
- url : /books/entry (POST)
- body {barcode, quantity}
Cart Module:
-
Add book to cart
- url : /cart/ (POST)
- body {barcode, quantity}
- add given quantity of book into user cart
-
Remove book from cart
- url : /cart/remove/:barcode (GET)
- remove all book with gievn barcode from users cart
-
Get cart
- url : /cart/ (GET)
- return cart of the loggedin user
Order Module:
-
Create order from user cart
- url : /orders/ (POST)
- get user cart and create and order for it
-
Get order
- url : /orders/ (GET)
- return all order of the current user