Skip to content

ajimae/e-commerce-app

Repository files navigation

e-commerce-app

A simple e-commerce application

Build Status Coverage Status

Table of Contents

API Deployment

API is deployed locally

Technologies

Supporting Packages

Compiler

  • Babel - Compiler for ES6 Javascript

Test Tools

  • Mocha - JavaScript Test Framework for API Tests
  • Chai - TDD/BDD Assertion Library for Node

Features

Users

  • Sign up an account
  • Login to the account

Prdouct

  • View available products
  • Post their own products
  • View a single product

Cart

  • Add items to their shopping cart
  • View all products items in their cart
  • Remove a specific item from cart

Order

  • Make an order
  • Cancel an order
  • Get all order
  • Fulfill an order

Getting Started

Installation

  • Clone the repository e-commerce-app.
  • Run yarn install to install packages.
  • Setup environment variables in your .env.
    • See .env.sample for sample variable keys
  • Run docker-compose up to build the docker containr and run the application.
  • Default base_url is at http://localhost/api/v1

Endpoints

Signup

url - http://localhost/api/v1/users
method: POST
request body: {
  "firstName": "firstName",
  "firstName": "firstName",
  "email": "email@mail.com",
  "password": "1234567890",
  "phone": "08012345678800"
}

Signin

url - http://localhost/api/v1/users
method: GET
request body: {
  "email": "email@mail.com",
  "password": "1234567890",
}

Product

url - http://localhost/api/v1/products
method: POST
Authorization: Bearer {{token}}
request body: {
  "name": "53\" Smart TV",
  "category": "electronics",
  "description": "Smart TV",
  "price": "85,000"
}

url - http://localhost/api/v1/products
method: GET

url - http://localhost/api/v1/product/{{productId}}
method: GET

Cart

url - http://localhost/api/v1/cart
method: GET
Authorization: Bearer {{token}}

url - http://localhost/api/v1/cart
method: POST
Authorization: Bearer {{token}}
request body: {
  "productId": "productId",
  "quantity": 1
}

url - http://localhost/api/v1/cart
method: PATCH
Authorization: Bearer {{token}}
request body: {
  "productId": ["productId-1", "productId-2", ...]
}

Order

url - http://localhost/api/v1/order
method: GET
Authorization: Bearer {{token}}

url - http://localhost/api/v1/order
method: POST
Authorization: Bearer {{token}}
request body: {
  "cartId": "cart-id"
}

url - http://localhost/api/v1/fulfill/{{orderId}}
method: POST
Authorization: Bearer {{token}}


url - http://localhost/api/v1/order/{{orderId}}
method: DELETE
Authorization: Bearer {{token}}

Testing

Prerequisites

Testing with Postman

  • After installing as shown above
  • Navigate to http://localhost/api/v1 in Postman to access the application endpoints.

Testing with Coverage Data

  • After installation
  • yarn test
  • It will lint code, run test and display coverage data as generated by nyc

Development

babe-node helps to compile es6 codes to es5 before for production deployment.

Schematics

schema

About

A simple e-commerce application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published