This is a simple API for managing products and images. It allows you to add products with associated images, retrieve products with their images, and delete products.
To run the API locally, follow these instructions:
Make sure you have Node.js and npm installed on your machine.
- Clone this repository to your local machine.
- Navigate to the project directory in your terminal.
- Install the required dependencies by running:
npm install
Create a .env
file in the root directory of the project and set the following environment variables:
DATABASE=leading-tech
USER=root
PASS=your_password
HOST=localhost
DILACT=mysql
JWT_CODE=your_secret_jwt_code
Replace your_password
and your_secret_jwt_code
with your actual database password and JWT secret code.
Run the server using the following command: npm run server
The API will start running on port 4500.
Retrieve a list of products along with their associated images.
Add a new product with associated images. Use the request body to provide product details and image URLs.
Example Request Body:
{
"name": "Product Name",
"SKU": "ABC123",
"images": ["url1.jpg", "url2.jpg"]
}
Retrieve a specific product by its ID along with its associated images.
Delete a product by its ID. This will also delete associated images.