Skip to content

Latest commit

 

History

History
40 lines (26 loc) · 1.49 KB

README.md

File metadata and controls

40 lines (26 loc) · 1.49 KB

A shopping-cart API implemented using express and Typescript. Items are persisted in memory.

CircleCI

Build Instructions

  • Install nodenv and node-build (or use any other way to put correct version of node on PATH).

  • Optionally, install jq package using homebrew, apt-get, yum etc. This is not required, but is useful for making the json returned by the API readable.

  • Run this to install the right version of node and start the cart API server:

nodenv install $(cat .node-version) # or non-nodenv equivalent
npm install
npm start
  • To access the API:
curl --verbose http://localhost:8080/cart # list all
curl --verbose -H "Content-Type: application/json" -d '{"item": {"title": "pumps", "price": 1999}}' http://localhost:8080/cart # add item
curl --verbose -X DELETE http://localhost:8080/cart # delete all
curl --verbose -X DELETE http://localhost:8080/cart/1 # delete by id
  • To use jq to pretty print the output from curl, append | jq . to the above commands.

Unit Tests

Unit tests use jest and (for HTTP testing) supertest. They can be run locally using:

npm test

IDE