Giter VIP home page Giter VIP logo

ecommerce-backend's Introduction

Ecommerce Back End

Description

This backend is a RESTful API that allows users to create, read, update, and delete products, categories anf tags.

Table of Contents

Installation

'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'

Setting up the database

run schema.sql at a mySQL prompt to create the database and tables.

source ./db/schema.sql

Seed the database:

npm run seed

API

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

Usage

Products

Get ALL Products

curl --request GET \
  --url http://localhost:3001/api/products
curl --request GET \
--url http://localhost:3001/api/products/7

Get a Product by Id

curl --request GET \
  --url http://localhost:3001/api/products/[id]

Add a Product

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]
}'

Update a Product

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]
}'

Delete a Product

curl --request DELETE \
  --url http://localhost:3001/api/products/[id]
    

Categories

Get ALL Categories

curl --request GET \
  --url http://localhost:3001/api/categories

Get a Category by ID

curl --request GET \
  --url http://localhost:3001/api/categories/[id]

Add a Category

curl --request POST \
  --url http://localhost:3001/api/categories \
  --header 'Content-Type: application/json' \
  --data '{
	"category_name": "category to add"
}'

Update a Category

curl --request PUT \
  --url http://localhost:3001/api/categories/[id] \
  --header 'Content-Type: application/json' \
  --data '{
		"category_name": "updated category name"
}'

Delete a Category

curl --request DELETE \
  --url http://localhost:3001/api/categories/[id]

Tags

Get ALL Tags

curl --request GET \
  --url http://localhost:3001/api/tags

Get a Tag by ID

curl --request GET \

    --url http://localhost:3001/api/tags/[id]

Add a Tag

curl --request POST \
  --url http://localhost:3001/api/tags \
  --header 'Content-Type: application/json' \
  --data '{
			"tag_name": "tag to add"
}'

Update a Tag

curl --request PUT \
    --url http://localhost:3001/api/tags/[id] \
    --header 'Content-Type: application/json' \
    --data '{
                "tag_name": "updated tag name"
}'

Delete a Tag

curl --request DELETE \
    --url http://localhost:3001/api/tags/[id]

License

This project is licenced under MIT

Questions

More of my work can be found here

ToDo

ecommerce-backend's People

Contributors

chrisaylen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.