This backend is a RESTful API that allows users to create, read, update, and delete products, categories anf tags.
'npm i' to install the necessary dependencies.
Create a file named .env with the following contents:
DB_USER=''
DB_PW=''
DB_NAME='ecommerce_db'
HOST=''
DIALECT='mysql'
run schema.sql at a mySQL prompt to create the database and tables.
source ./db/schema.sql
Seed the database:
npm run seed
The application surfaces a RestFul API that has the following endpoints:
/api/products
/api/products/:id
/api/categories
/api/categories/:id
/api/tags
/api/tags/:id
curl --request GET \
--url http://localhost:3001/api/products
curl --request GET \
--url http://localhost:3001/api/products/7
curl --request GET \
--url http://localhost:3001/api/products/[id]
curl --request POST \
--url http://localhost:3001/api/products \
--header 'Content-Type: application/json' \
--data '{
"product_name": "PingPongball",
"price": 299.99,
"stock": 6,
"tagIds": [1,2,3,4,5]
}'
curl --request PUT \
--url http://localhost:3001/api/products/[id] \
--header 'Content-Type: application/json' \
--data '{
"product_name": "product name",
"price": 300.00,
"stock": 7,
"tagIds": [1,2,3,4]
}'
curl --request DELETE \
--url http://localhost:3001/api/products/[id]
curl --request GET \
--url http://localhost:3001/api/categories
curl --request GET \
--url http://localhost:3001/api/categories/[id]
curl --request POST \
--url http://localhost:3001/api/categories \
--header 'Content-Type: application/json' \
--data '{
"category_name": "category to add"
}'
curl --request PUT \
--url http://localhost:3001/api/categories/[id] \
--header 'Content-Type: application/json' \
--data '{
"category_name": "updated category name"
}'
curl --request DELETE \
--url http://localhost:3001/api/categories/[id]
curl --request GET \
--url http://localhost:3001/api/tags
curl --request GET \
--url http://localhost:3001/api/tags/[id]
curl --request POST \
--url http://localhost:3001/api/tags \
--header 'Content-Type: application/json' \
--data '{
"tag_name": "tag to add"
}'
curl --request PUT \
--url http://localhost:3001/api/tags/[id] \
--header 'Content-Type: application/json' \
--data '{
"tag_name": "updated tag name"
}'
curl --request DELETE \
--url http://localhost:3001/api/tags/[id]
This project is licenced under MIT