This project is an Express-based API for managing products and orders. It includes routes for fetching products based on various criteria and a random selection of products, as well as a simple root route.
- Clone the repository:
git clone https://github.com/yourusername/yourrepository.git
- Navigate to the project directory:
cd yourrepository - Install the dependencies:
npm install
- Start the server:
npm start
- The server will start on
http://localhost:3000.
-
Get All Products
- Endpoint:
/products - Method:
GET - Description: Fetch all products from the database.
- Endpoint:
-
Get Product by ID
- Endpoint:
/products/id/:id - Method:
GET - Description: Fetch a product by its ID.
- Endpoint:
-
Get Products by Category
- Endpoint:
/products/category/:category - Method:
GET - Description: Fetch products by category name.
- Endpoint:
-
Get Products by Sub-Category
- Endpoint:
/products/subcategory/:sub_category - Method:
GET - Description: Fetch products by sub-category name.
- Endpoint:
-
Get Products by Name
- Endpoint:
/products/name/:name - Method:
GET - Description: Fetch products by name.
- Endpoint:
-
Get Random Products
- Endpoint:
/products/random - Method:
GET - Description: Fetch a random selection of 6 products.
- Endpoint:
- Get All Orders
- Endpoint:
/orders - Method:
GET - Description: Fetch all orders from the database.
- Endpoint:
- Root Route
- Endpoint:
/ - Method:
GET - Description: Root endpoint for the API.
- Endpoint:
project/ │ ├── controllers/ │ ├── products/ │ │ └── productcontroller.js │ ├── orders/ │ │ └── ordercontroller.js │ └── rootcontroller.js │ ├── models/ │ └── ProductSchema.js │ ├── routes/ │ ├── productRoutes.js │ ├── orderRoutes.js │ └── rootRoutes.js │ ├── app.js └── README.md