Skip to content

FayK12/MarketPlaceApplication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MarketPlaceApplication

Prerequisites

  • You'll need to install the latest stable release of Node.js and npm.
  • Check out https://nodejs.org/ to download.
  • Follow the installation steps.
  • Once setup, launch command prompt and confirm via the following commands
node -v 

Node was v8.11.4 for me

npm -v 

NPM was v6.4.1 for me

Setup

npm install

This does a local install of the node modules you'll need based on the package.json file.

  • Enter the command
node app.js

This starts the server at https://localhost:3000/

Marketplace How To's

  • For all products:
GET https://localhost:3000/api/list
  • For available inventory items:
GET https://localhost:3000/api/list?inventory=true
  • To make a purchase, use its id:
PUT https://localhost:3000/api/products/:id

For example

https://localhost:3000/api/products/id_1
  • Revisit the GET API https://localhost:3000/api/list and you'll notice the inventory count has decreased by 1
  • You're unable to purchase an out of stock item or if enough purchases reduce its inventory to 0. On purchasing an out-of-stock item, a message will pop up stating the item is out of stock

All Marketplace products are persisted in a JSON file. This 'mock db' was done for simplicity but ideally Mongo DB or SQL databases would be used

Postman

You'll find an export of postman collections used in testing the GET and PUT APIs. In order to use the same collection, please import the collection found in the folder 'postman'

About

Coding exercise

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published