You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			|  | 2 years ago | |
|---|---|---|
| .. | ||
| controllers | 2 years ago | |
| model | 2 years ago | |
| routes | 2 years ago | |
| .env | 2 years ago | |
| .gitignore | 2 years ago | |
| .prettierrc | 2 years ago | |
| Procfile | 2 years ago | |
| auth.js | 2 years ago | |
| csp2-postman.json | 2 years ago | |
| index.js | 2 years ago | |
| package-lock.json | 2 years ago | |
| package.json | 2 years ago | |
| readme.md | 2 years ago | |
		
			
				
				readme.md
			
		
		
			
			
		
	
	E-COMMERCE API DOCUMENTATION
INSTALLATION COMMAND:
npm install bcrypt cors dotenv express faker jsonwebtoken mongoose nodemon
Start npm start
TEST ACCOUNTS:
- Regular User:
- email: user@email.com
- pwd: user
 
- Admin User:
- email: admin@email.com
- pwd: admin
 
ROUTES:
- 
User registration (POST) - http://localhost:3000/user/register
- auth header required: NO
- request body: { "email": "admin@email.com", "password": "admin" }
 
 
- http://localhost:3000/user/register
- 
User authentication (POST) - http://localhost:3000/user/login
- auth header required: NO
- request body: { "email": "admin@email.com", "password": "admin" }
 
 
- http://localhost:3000/user/login
- 
Create Product (Admin only) (POST) - http://localhost:4000/product/create
- auth header required: YES
- request body: { "name": "Poring Card", "description": "Description unknown", "price": 500 }
 
 
- http://localhost:4000/product/create
- 
Update Profile - http://localhost:3000/user/update
- auth header required: YES
- request body: { "userId": "", "newEmail": "", "newFirstname": "", "newLastName": "", "newPassword": "" }
 
 
- http://localhost:3000/user/update
- 
Retrieve all products (Admin only) (GET) - http://localhost:3000/product/all
- auth header required: YES
- request body: none
 
 
- http://localhost:3000/product/all
- 
Retrieve all active products (GET) - http://localhost:3000/product/active
- auth header required: NO
- request body: none
 
 
- http://localhost:3000/product/active
- 
Get all products (GET) - http://localhost:3000/product/active
- auth header required: NO
- request body: none
 
 
- http://localhost:3000/product/active
- 
Get a product (GET) - http://localhost:3000/product/products/65545a1e6fa9d841e1518d1d
- auth header required: YES
- request body: none
 
 
- http://localhost:3000/product/products/65545a1e6fa9d841e1518d1d
- 
Update Single product (PUT) - http://localhost:3000/product/products/65545a1e6fa9d841e1518d1d
- auth header required: YES
- request body: { "name": "Christmas Cookie Card", "description": "Updated Product Description", "price": 29.99, "isActive": false }
 
 
- http://localhost:3000/product/products/65545a1e6fa9d841e1518d1d
- 
Create Order (POST) - http://localhost:3000/user/order
- auth header required: YES
- request body: { "userId": "65535cb526b586a3e2fd56cc", // Replace with a valid user ID from your database "products": [ { "productId": "6553a4e897ac8ac9462f96c4", // Replace with a valid product ID from your database "productName": "Mastering Card", "quantity": 1 } ], "totalAmount": 500 }
 
 
- http://localhost:3000/user/order
- 
Activate / Archive Product (PUT) - auth header required: YES
- request body: none
- http://localhost:3000/product/products/6554634e5cac4bcd6f2394ed/activate
- http://localhost:3000/product/products/6554634e5cac4bcd6f2394ed/archive
 
- 
Set User to Admin (POST) [Admin Only] - hhttp://localhost:3000/user/set-admin/ - auth header required: YES - request body: { "userId": } 
- 
Retrieve All Orders [Admin Only] (GET) - http://localhost:3000/user/orders-all
- auth header required: YES
- request body: none
 
- 
Add To Cart (POST) - http://localhost:3000/cart/add-to-cart
- auth header required: YES
- request body: { "userId": "655396dcc8ea29f42422e214", "productId": "6553a54566c4c86c39034b55", "quantity": 5 }
 
- 
Delete Item (DELETE) - http://localhost:3000/cart/remove-from-cart
- auth header required: YES
- request body: { "userId": "655396dcc8ea29f42422e214", "productId": "6553a54566c4c86c39034b55", "quantity": 5 }
 
- 
Update Quantity (PUT) - http://localhost:3000/cart//update-quantity
- auth header required: YES
- request body: { "userId": "655396dcc8ea29f42422e214", "productId": "6553a55666c4c86c39034b59", "quantity": 2000 }
 
- 
Cart Total (GET) - http://localhost:3000/cart/cart-details
- auth header required: YES
- request body: { "userId": "655396dcc8ea29f42422e214" }
 
** Stretch Goals **
- Set user as Admin ( Admin Only )
- Retrieve Authenticated User's Orders
- Retrieve all orders ( Admin Only )
- Add to Cart ( Added Products, Change Product Quantities, Remove Products From Cart, Subtotal for each item, Total price for all items)
- Authentication Token with expiration (1hr)
- dotenv
- faker (Auto Generate Names)
- getUserDetails function ( Detects if the user tries to get the details of the other useId's + Token auth)
- Middleware Secure verification that match Token and UserId to next()