[JITERA] Implement Product Image Service
Created by: chi-jitera
Overview
This pull request introduces a new service for managing product images, following the structure and conventions established in the existing bookService.js. The new service, productImageService.js, provides a complete set of CRUD operations for product images, including validation and error handling.
Changes
-
Service Structure:
- Created a new file named
productImageService.jsin theservicesdirectory. - Imported the necessary
ProductImagemodel.
- Created a new file named
-
CRUD Operations:
-
Create: Implemented
createProductImagefunction to add a new product image with validation. -
Read: Implemented
getAllProductImagesto retrieve all product images andgetProductImageByIdto fetch a specific image by its ID. -
Update: Implemented
updateProductImageto modify existing product image details with validation. -
Delete: Implemented
deleteProductImageto remove a product image by its ID.
-
Create: Implemented
-
Validation:
- Added
validateProductImageDatafunction to ensure that the image data includes a valid URL and can be expanded for additional validation rules.
- Added
-
Error Handling:
- Included error handling for scenarios where a product image is not found during read, update, or delete operations.
This service lays the groundwork for further enhancements and integrations related to product images in the application.