- 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
- Create a folder on your desktop. Download the repo here & unzip the contents: https://github.com/FayK12/MarketPlaceApplication
- Delete the node modules folder
- Open command prompt and navigate to the folder with the unzipped contents
- Enter the command
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/
- 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
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'