Giter VIP home page Giter VIP logo

ecomm-backend's Introduction

E-commerce Back End

license issues

Back end access for ecommerce retail business with SQL database.

Table of Contents

Description

E-commerce Back End provides access to the back end for an e-commerce site. It uses an Express.js server, RESTful APIs, and Sequelize to interact with a MySQL database. It offers create, read, update, and delete functionality.

Installation

Prequisites

This application requires that you have Node.js, MySQL server, and the MySQL shell. The server and database connection also require environment variables, so create .env file in the root folder of the project, then add the following information:

DB_NAME='ecommerce_db'
DB_USER='<your_user>'
DB_PW='<your_password>'

Now the server can connect to your database automatically on launch.

Getting Started

Navigate to the root folder of the application from you CLI. Install the dependencies with the command npm i. Once the project is intalled, connect to your database:

mysql -u <your_user> -p

Leave out -p if you're not using a password. Next, create the database. From the mysql shell, run the folowing command:

source db/schema.sql

Close the mysql shell. Ecommerce Backend is now installed and your database is ready to use. If you'd like to use the example records included with this project, run the command npm run seed.

Usage

Watch this walkthrough video for a detailed view of each route and request body.

To launch the app, navigate to the root folder of the project from your CLI. Run the command npm start or node server.js.

Next, launch your API testing client (like Insomnia) and enter the HTTP address where your server is running, most likely http://localhost:3001 (the port will be logged to the console once the server starts), with the route you'd like to use (for example /api/categories). Get and delete routes do not require a request body. Put and post routes (update and create, respectively), require a JSON request body.

Here are some examples of the API in action:

GET Routes

There are two Read options available: GET all and GET one by id. To get a single record, simply add the record id to the end of the HTTP address.

get preview

POST Routes

New categories require category_name in the request body. Tags take tag_name as the request body. Products require more information; include prduct_name, price, and stock. If stock is left blank, it will default to 10. You may optionally include category_id and tagIds (as an array), but they are not required for product creation.

post preview

PUT Routes

You cannot change a record's id. You can make changes to any other field. Products do not require that your enter every property into the JSON request, only the propeties that you wish to alter. Remember to include the record's id at the end of the HTTP address.

put preview

DELETE Routes

To delete a record, include the record's id at the end of the HTTP address.

delete preview

Contributions

This project uses the following packages:

Code for the server was provided in the curricullum for Columbia University's Full-Stack Bootcamp.

License license

This is an open source project and falls under an ISC license.

Questions and Contact

Back end written by Lelah Bates Childs.

You can find me on GitHub @labchild or email me. If you have any questions about this project, please reach out.

If you encounter any bugs or other problems, submit an issue.

Want to Help?

Do you see something I missed or a more succint and effective way this code can be written? Great! Please reach out and let me know how I can improve. Thanks in advance for your tips, tricks, and pointers!

Acknowledgements

Thank you to my bootcamp instructional team and cohort, for helping me along this journey to become a developer.

ecomm-backend's People

Contributors

labchild avatar xandromus avatar dependabot[bot] avatar

Watchers

 avatar

ecomm-backend's Issues

Walkthrough video

  • demonstrate how to create the schema from the MySQL shell
  • demonstrate how to seed the database from the command line
  • demonstrate how to start the application’s server
  • demonstrate GET routes for all categories, all products, and all tags being tested in Insomnia
  • demonstrate GET routes for a single category, a single product, and a single tag being tested in Insomnia
  • demonstrate POST, PUT, and DELETE routes for categories, products, and tags being tested in Insomnia
  • add video link to readme

create models

Category

  • id
    • int
    • not null
    • PK
    • auto increment
  • category_name
    • str
    • not null

Product

  • id
    • int
    • not null
    • PK
    • auto increment
  • product_name
    • str
    • not null
  • price
    • decimal
    • not null
    • validates value is a decimal
  • stock
    • int
    • not null
    • default: 10
    • validates value is num
  • category_id
    • int
    • reference category.id

Tag

  • id
    • int
    • not null
    • PK
    • auto increment
  • tag_name
    • str

ProductTag

  • id
    • int
    • not null
    • PK
    • auto increment
  • product_id
    • int
    • references product.id
  • tag_id
    • int
    • references tag.id

model associations

  • product belongs to category
  • category can have many products
  • product belongs to many tags
    • Using the ProductTag through model, allow products to have multiple tags and tags to have many products
  • tag belongs to many products

add Sequelize to API routes

  • sync sequelize models to server on start
  • use sequelize to query the db in API calls
  • create/complete all CRUD routes

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.