GuilhermeMLS / typescript-ecommerce-example

A simple e-commerce REST API built with TypeScript to learn and practice design patterns.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeScript E-commerce Example

Status Status

A simple e-commerce REST API built with TypeScript to learn and practice design patterns.

Stack

Installation

  1. $ git clone https://github.com/GuilhermeMLS/typescript-ecommerce-example.git

  2. $ cd typescript-ecommerce-example/

  3. $ npm install

  4. $ npm start

Docs

  • Simulate a checkout action

    • Endpoint: GET /:cartId
    • Response:
      {
          "cartId": "123ABC",
          "value": 4500,
          "items": [
              {
                  "name": "Couch",
                  "value": 3200,
                  "id": 1
              },
              {
                  "name": "Bed",
                  "value": 700,
                  "id": 2
              },
              {
                  "name": "Desk",
                  "value": 600,
                  "id": 3
              }
          ],
          "paymentMethods": [
              {
                  "name": "Credit Card",
                  "tax": 0.05,
                  "valueToPay": 4725
              },
              {
                  "name": "Boleto",
                  "tax": 0,
                  "valueToPay": 4500
              },
              {
                  "name": "Financing",
                  "tax": 0.12,
                  "valueToPay": 5040
              }
          ],
          "shippingAddress": {
              "street": "R. Marechal Deodoro",
              "number": 1001
          }
      }
  • Simulate a payment action

    • Endpoint: POST /
    • Body:
      {
          "cartId": "123ABC",
          "paymentMethod": {
              "id": 1
          }
      } 
    • Response:
      {
          "items": [
              {
                  "name": "Couch",
                  "value": 3200,
                  "id": 1
              },
              {
                  "name": "Bed",
                  "value": 700,
                  "id": 2
              },
              {
                  "name": "Desk",
                  "value": 600,
                  "id": 3
              }
          ],
          "value": 4725,
          "shippingAddress": {
              "street": "R. Marechal Deodoro",
              "number": 1001
          },
          "paymentMethod": {
              "id": 1,
              "name": "Credit Card",
              "tax": 0.05
          },
          "createdAt": 1593219325744
      }

About

A simple e-commerce REST API built with TypeScript to learn and practice design patterns.


Languages

Language:TypeScript 100.0%