This repository contains the code for a simple Products App. The app allows you to manage brands and products associated with those brands. It provides basic CRUD (Create, Read, Update, Delete) operations for both brands and products.
Before you begin, make sure you have the following prerequisites installed:
- Node.js and npm: You can download and install them from https://nodejs.org/.
-
Clone the repository:
git clone <repository-url>
-
Install the required dependencies:
npm install
-
Start the server:
npm start
-
The server will start running at http://localhost:8000/.
The app uses a MySQL database with two tables: brands and products. Here is the schema:
id (Primary Key)
brand_name (String)
id (Primary Key)
product_name (String)
description (Text)
price (Decimal)
stock (Integer)
brands_id (Foreign Key referencing brands.id)
GET /brand: Get all brands.
GET /brand/:id: Get a brand by ID.
GET /brand/:id/brandproducts: Get products by brand ID.
POST /brand: Create a new brand.
PUT /brand/:id: Update a brand by ID.
DELETE /brand/:id: Delete a brand by ID.
GET /products: Get all products.
GET /products/:id: Get a product by ID.
POST /products: Create a new product.
PUT /products/:id: Update a product by ID.
DELETE /products/:id: Delete a product by ID.
The repository includes unit tests for the API endpoints. You can run the tests using the following command:
```sh
npm test
Happy coding!