vinicbarros / Pitchau-Back

This is the back-end project of the Tech E-Commerce app built with Node.js + Express + MongoDB! This website was inspired on the tech store called Pichau! It was the fourteenth project of Driven Full Stack Web Development bootcamp.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Pitchau

E-Commerce Web APP | Back-End Project


This is a FullStack project of a complete E-Commerce APP. Pitchau was inspired in the tech store of Pichau!

This repository is just Back-End, you can find the Front-End part in my github profile!


About

Pithcau E-Commerce was made for the fourteenth project of Driven Full Stack Web Development bootcamp. And it was made by two amazing developers who loves technology and games!

Features

  • Log in
  • Sign up
  • Authentication routes for registering and logging in
  • You can see all products in the store
  • You can filter for categories in the navigation bar
  • You can add and remove products to your cart
  • See what products are in your cart
  • Checkout page
  • Number of products in your cart shows dinamically in the top cart icon
  • Finish buy using just a fake card

API Features

  • Insert new products (Authenticated Router)
  • Get products (Authenticated Router)
  • Sign In and Sign Up route
  • Add, remove products to your cart
  • Checkout route

Built with

Node Express MongoDB Visual Studio Code

How to run (You need MongoDB installed to continue)

  1. Clone the project
  git clone https://github.com/vinicbarros/Pitchau-Back.git
  1. Go to the project directory
  cd Pitchau-Back
  1. Install dependencies
  npm install
  1. Go to src directory
  cd src
  1. Before running server, make sure that MongoDB is running in your machine and a db called "pitchau" is created

  2. Start the server

  npm run dev

API documentation



Create new account


  POST /sign-up

Body:

{
  "name": "Pedro",
  "email": "pedro@gmail.com",
  "password": "secret"
}

Response:

  • Invalid Body
"status": 400
  • Email is already in use
"status": 409
  • Account is created
"status": 201

Log in to your account


  POST /sign-in

Body:

{
  "email": "pedro@gmail.com",
  "password": "secret"
}

Response:

  • Invalid Body
"status": 400
  • Email and password do not match
"status": 404
  • User is logged in
"status": 202

Response Body:

{
  "user": {
    "id": 1,
    "name": "Pedro",
    "email": "pedro@gmail.com"
  },
  "token": "token"
}

All routes below are authenticated routes and will use an authorization header as shown below

Instead of "token", use your own token acquired through the /sign-in route

{
  "headers": {
    "Authorization": "Bearer token"
  }
}

Create new product


  POST /products

Body:

{
  "nameProduct": "Headset Gamer With LED",
  "img": "https://image.png",
  "category": "Headset",
  "description": "Best headset",
  "price": 10099
}

Response:

  • Invalid Body
"status": 400
  • Product is created
"status": 201

Return all products


  GET /products

Response:

{
  "products": [
    {
      "_id": "1",
      "nameProduct": "Notebook gamer",
      "img": "https://notebookimage.png",
      "category": "Notebook",
      "description": "The best notebook ever!",
      "price": 128099
    }
  ]
}

Returns the filtered products by category


  GET /products?category={category}
Parâmetro Tipo Descrição
category string Needs to be a valid category

Response:

{
  "products": [
    {
      "_id": "1",
      "nameProduct": "Notebook gamer",
      "img": "https://notebookimage.png",
      "category": "Notebook",
      "description": "The best notebook ever!",
      "price": 128099
    }
  ]
}

Finish buy


  POST /checkout

Body:

{
  "method": "Credit",
  "payment": "",
  "numberCard": 123456789,
  "cvv": 123,
  "products": []
}

Response:

  • Invalid Body
"status": 404
  • Buy completed
"status": 200

Post cart


  POST /cart

Body:

{
  "productId": 12
}

Response:

  • Invalid Body
"status": 401
  • Product added
"status": 201

Get cart


  GET /cart

Response:

  • Invalid Body
"status": 401
  • Status OK
{
  "userCartList": [
    {
      "_id": "1",
      "userId": "1",
      "productId": "2",
      "name": "Monitor ",
      "img": "https://monitor.jpg",
      "description": "The best!",
      "price": 72999
    }
  ]
}

Delete product of cart by id


  DELETE /cart/:id
Parâmetro Tipo Descrição
id string Needs to be a valid id

Response:

  • Invalid Params
"status": 404
  • Item deleted
"status": 200

Contact

Feel free to contact me in Linkedin!

LinkedIn

About

This is the back-end project of the Tech E-Commerce app built with Node.js + Express + MongoDB! This website was inspired on the tech store called Pichau! It was the fourteenth project of Driven Full Stack Web Development bootcamp.


Languages

Language:JavaScript 100.0%