API for registering users with mongodb and authentication using a JWT (json web token). This app uses passport and passport-jwt and uses a JWT strategy
1.0.0
npm installnpm start| Field | Description |
|---|---|
| id | The item's unique id. |
| name | Name of customer. |
| Email of customer. | |
| username | Username of customer. |
| title | Name of product. |
| price | Price of product. |
| inventory_count | Number of product in inventory. |
| excludeUnavailable | Boolean describing whether unavailable inventory is to be excluded from search |
All API calls must contain the following headers
| Key | Value |
|---|---|
| Content-Type | application/json |
All endpoints listed below contain the endpoint, a live endpoint on Heroku, and a sample call.
POST /product/create // Adds product to databaseLive endpoint: https://shopifybackendtest.herokuapp.com/product/create
{
"title": "testProduct",
"price": 3,
"inventory_count": 3
}POST /product/fetch // Fetches productLive endpoint: https://shopifybackendtest.herokuapp.com/product/fetch
{
"title": "testProduct"
}POST /product/fetchall // Fetches all productsLive endpoint: https://shopifybackendtest.herokuapp.com/product/fetchall
{
"excludeUnavailable": true
}POST /product/purchase // Purchases product, decreasing inventory_count by 1Live endpoint: https://shopifybackendtest.herokuapp.com/product/purchase
{
"title": "testProduct"
}Fetch products contained in default user(username: test123)'s cart.
GET /product/viewCart // Fetches cartLive endpoint: https://shopifybackendtest.herokuapp.com/product/viewCart
{ }Adds item to cart, but the product stays in the inventory (inventory_count doesn't change)
POST /product/addToCart // Adds item to cartLive endpoint: https://shopifybackendtest.herokuapp.com/product/addToCart
{
"title": "testProduct"
}Purchases all items in default user(username: test123)'s cart and empties the cart
POST /product/checkout // Checkout of all items in cartLive endpoint: https://shopifybackendtest.herokuapp.com/product/checkout
{ }POST /users/register // Adds user to databasePOST /users/authenticate // Gives back a token