This is a backend Node.js Express application that returns server-rendered HTML files. The HTML files are dynamic in nature, providing a seamless experience for managing products and categories. It supports CRUD (Create, Read, Update, Delete) operations for both categories and products. You can also fetch all the products associated with a specific category, making it simple to manage product-category relationships.
- Frontend: HTML, CSS, Vanilla JavaScript
- Backend: Node.js, Express , Ejs
- Database: MySQL
-
Category Management:
- Add new categories βοΈ
- Update existing categories π
- Delete categories ποΈ
- Fetch all categories π
categories.mp4
-
Product Management:
- Add new products π
- Assign products to categories π¦
- Update product details βοΈ
- Delete products ποΈ
products.mp4
-
Fetch all products for a specific category π
products-by-category.mp4
-
Pagination:
- Navigate through categories and products with pagination π
| Route | HTTP Method | Functionality | Parameters | Source |
|---|---|---|---|---|
/api/products |
GET |
Fetch all products with pagination | Query: page (optional, number), pageSize (optional, number) |
Query Params |
/api/products/:id |
GET |
Fetch a specific product by its ID | Path: id (required, product ID) |
Path Param |
/api/products |
POST |
Add a new product | Body: product_name (string), category_id (number) |
JSON Body |
/api/products/:id |
PUT |
Update an existing product | Path: id (required, product ID) Body: product_name (string), category_id (number) |
Path + JSON |
/api/products/:id |
DELETE |
Delete a product by its ID | Path: id (required, product ID) |
Path Param |
| Route | HTTP Method | Functionality | Parameters | Source |
|---|---|---|---|---|
/api/categories |
GET |
Fetch all categories with pagination | Query: page (optional, number), pageSize (optional, number) |
Query Params |
/api/categories/:id |
GET |
Fetch a specific category by its ID | Path: id (required, category ID) |
Path Param |
/api/categories |
POST |
Add a new category | Body: category_name (string) |
JSON Body |
/api/categories/:id |
PUT |
Update an existing category | Path: id (required, category ID) Body: category_name (string) |
Path + JSON |
/api/categories/:id |
DELETE |
Delete a category by its ID | Path: id (required, category ID) |
Path Param |
/api/categories/category/:id |
GET |
Fetch all products for a specific category | Path: id (required, category ID) |
Path Param |
- Pagination: Both
productsandcategoriessupport pagination using optionalpageandpageSizequery parameters. - Parameter Handling:
- Path Parameters: For resource identification, e.g.,
:id. - Query Parameters: For filtering or pagination, e.g.,
page,pageSize. - JSON Body: For creating or updating resources.
- Path Parameters: For resource identification, e.g.,