This is web service that exposes APIs to purchase and fetch products.
- node version 9.9 or later
- npm 6.6 or later
- Download dependencies:
npm install
- Start server:
npm start
- Server will be available at port 80:
http://localhost:80
Fetches all available products. Optionally ?available=true
might be passed in order to only return products with available inventory.
Fetches the information about a single product.
This is used for updating a single product. For now, it only supports decrementing the inventory by 1, by passing {"action":"purchase"}
as the request body.
This is still in development. Server is initialized with hardcoded products. In future, storage/database might be used to persist product changes across server instances.
- Make sure the server is running
- Run command:
npm test
Note: to re-run tests, server must to be restarted in order to reset original product attributes