Code Monkey home page Code Monkey logo

cart-api's Introduction

Cart API

Shopping cart API developed with Node.js

GitHub repo size GitHub last commit GitHub Repo stars Coverage

๐Ÿ›’ Project

REST API that implements the shopping cart behaviors. This project was developed using the stack Typescript + Node.js + PostgreSQL stack and applying the Clean Architecture concepts and SOLID principles.

๐Ÿ’ก Requirements

  • Save cart data
  • Get cart data
  • Add an item to cart
  • Remove an item from cart
  • Update the quantity of a cart item
  • Clear cart items
  • Apply a discount coupon to cart

๐ŸŽฒ Running

In order to run the API in development environment, you must have at least the following tools installed: Git, Docker and Docker Compose.

# Clone repository
$ git clone [email protected]:viniciusmeneses/cart-api.git

# Go to project directory
$ cd cart-api

# Make a copy of envs configuration file
$ cp .env.sample .env

# Create database and start the server
$ docker-compose up -d

# Run database migrations
$ docker exec -t cart-api yarn migration:run

The API will be served on port 3000 by default and it can be accessed by URL http://localhost:3000.

๐Ÿ“„ Docs

Every endpoint and your returns were documented using Swagger and can be accessed by the path /docs.

Test data

The following data will be inserted into the database when you run the migrations. It can be used when doing requests to endpoints that need an existing product or coupon.

// Products
{ id: "779d7f21-05b7-4a74-82e5-68b43c7d42d4", name: "T-shirt", price: 45.0, stock: 10 }
{ id: "a5d66c1a-b540-45ec-aab7-1e7dc932c38f", name: "Pants", price: 90.0, stock: 10 }
{ id: "c2f6dd0e-763e-4600-ad6f-0699be6ba5ae", name: "Sneakers", price: 199.99, stock: 3 }
{ id: "c98b3118-677d-4aec-9b06-d20f0015a5ac", name: "Sweatshirt", price: 149.99, stock: 5 }
{ id: "9450ea85-ab39-4d06-ae9f-8cd7f20ed4e6", name: "Cap", price: 20.0, stock: 4 }

// Discount coupons
{ id: "f99458a3-918e-4275-83bc-f62d5a891480", code: "GHW2O", percentage: 10.0 }
{ id: "695ba12a-7b9d-4c5d-8d70-649583590a34", code: "VEFJY", percentage: 5.0 }
{ id: "c4a9f80d-8ecc-4870-82f1-c436ac18581f", code: "D0JNN", percentage: 2.5 }

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.