simple Node.js API for food shop
- Node.js v 6.10.0
- Open './config/config.json' and specify all needable data (mongoUri, port, deleteTimeout). To install mongoDB you can use 'https://1cloud.ru/help/linux/Ustanovka-MongoDB-na-Ubuntu' for Ubuntu.
- install node modules: "npm install"
- fill test DB: "node ./lib/fillDb" (data is retrieving from ./config/config.json)
- run tests: "npm test" (Note that it used test db in tests)
- run application "npm start"
Requests could be send for example with Postman (https://www.getpostman.com/):
- get available products list: GET localhost:3000/api/products
- get your cart: GET localhost:3000/api/cart (cart is identified by sessionID and will be deleted in 5 min after last activity with cart)
- add product to cart: POST localhost:3000/api/cart Body={ "product_id": "2", "quantity": 2 } (quantity should be integer in range [1,10])
- delete product from cart: DEL localhost:3000/api/cart Body={"product_id": "2"}