This project is a backend application for an e-commerce site. It uses Express.js for the server, Sequelize as the ORM, and MySQL as the database. The application provides APIs to manage products, categories, and tags.
-
Clone the repository:
git clone https://github.com/your-username/fantastic-umbrella.git cd fantastic-umbrella -
Install dependencies:
npm install
-
Create a
.envfile in the root directory and add the following environment variables:DB_NAME= DB_USER= DB_PASSWORD= DB_PORT= DB_HOST= DB_DIALECT=mysql
-
Create the database schema and seed the database:
npm run schema npm run seed
-
Start the application:
npm start
-
Start the server:
npm start
-
Use Insomnia Core to test the API endpoints.
-
Get All Categories
- Filepath:
/api/categories - Method:
GET - Response: JSON array of all categories
- Filepath:
-
Get Category by ID
- Filepath:
/api/categories/:id - Method:
GET - Response: JSON object of the category with the given ID
- Filepath:
-
Create a New Category
- Filepath:
/api/categories - Method:
POST - Request Body:
{ "category_name": "New Category" } - Response: JSON object of the created category
- Filepath:
-
Update a Category by ID
- Filepath:
/api/categories/:id - Method:
PUT - Request Body:
{ "category_name": "Updated Category" } - Response: JSON object of the updated category
- Filepath:
-
Delete a Category by ID
- Filepath:
/api/categories/:id - Method:
DELETE - Response: JSON message confirming deletion
- Filepath:
-
Get All Products
- Filepath:
/api/products - Method:
GET - Response: JSON array of all products
- Filepath:
-
Get Product by ID
- Filepath:
/api/products/:id - Method:
GET - Response: JSON object of the product with the given ID
- Filepath:
-
Create a New Product
- Filepath:
/api/products - Method:
POST - Request Body:
{ "product_name": "New Product", "price": 100.00, "stock": 10, "category_id": 1, "tagIds": [1, 2] } - Response: JSON object of the created product
- Filepath:
-
Update a Product by ID
- Filepath:
/api/products/:id - Method:
PUT - Request Body:
{ "product_name": "Updated Product", "price": 150.00, "stock": 20, "category_id": 2, "tagIds": [3, 4] } - Response: JSON object of the updated product
- Filepath:
-
Delete a Product by ID
- Filepath:
/api/products/:id - Method:
DELETE - Response: JSON message confirming deletion
- Filepath:
-
Get All Tags
- Filepath:
/api/tags - Method:
GET - Response: JSON array of all tags
- Filepath:
-
Get Tag by ID
- Filepath:
/api/tags/:id - Method:
GET - Response: JSON object of the tag with the given ID
- Filepath:
-
Create a New Tag
- Filepath:
/api/tags - Method:
POST - Request Body:
{ "tag_name": "New Tag" } - Response: JSON object of the created tag
- Filepath:
-
Update a Tag by ID
- Filepath:
/api/tags/:id - Method:
PUT - Request Body:
{ "tag_name": "Updated Tag" } - Response: JSON object of the updated tag
- Filepath:
-
Delete a Tag by ID
- Filepath:
/api/tags/:id - Method:
DELETE - Response: JSON message confirming deletion
- Filepath: