Full-Stack Backend Operations in Node.js
You are developing a RESTful API for an e-commerce application using Node.js, Express, and MongoDB. The system should support the following functionalities:
- User Authentication: Implement JWT-based authentication with password hashing using bcrypt.
- Product Management (CRUD Operations):
- Create a new product with fields:
name, description, price, category, and stock.
- Retrieve a paginated list of products with optional filtering by category.
- Update product details (only admin users can update).
- Delete a product (only admin users can delete).
- Order Processing:
- Users should be able to place an order with multiple products.
- The total order amount should be calculated dynamically.
- The product stock should be reduced after an order is placed.
- Middleware Operations:
- Implement a middleware that logs API request details (method, URL, timestamp).
- Implement role-based access control for admin-only operations.
- Error Handling:
- Implement centralized error handling for invalid requests and database errors.
Submission Guidelines
- Submit your gitHub repo
- Make sure it has a proper readme with a proper documentation with all the end points