npm run fill-db # fills database with 25 mock bike items
curl http://localhost:3000/bikes/all | jq .
curl http://localhost:3000/bikes/<ID> | jq . # replace <ID> with an ID from the response to /all
curl http://localhost:3000/bikes/by-handle/<HANDLE> | jq . # replace <HANDLE> with a handle from the response to /all
curl http://localhost:3000/bikes/search/by-title\?query\=Bicycle | jq .
Creating and Replacing Bikes (Authentication required!)
// request.json (remove this line from the actual file!)
{
"productType": "Hybrid Bicycle",
"createdAt": "Fri Jan 28 2022 03:13:24 GMT+0100 (GMT+02:00)",
"vendor": "Audi",
"totalInventory": 2,
"availableForSale": false,
"priceRange": {
"minPrice": {
"currencyCode": "USD",
"amount": 1160
},
"maxPrice": {
"currencyCode": "USD",
"amount": 1624
}
},
"description": "Autem ipsam quasi omnis ut. Et officiis quia. Sed quaerat pariatur nihil nobis est quos earum quidem.",
"title": "Hybrid Bicycle Sentra"
}
export TOKEN=<TOKEN> # replace <TOKEN> with the token from /api/user
curl -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" http://localhost:3000/bikes/ -d @request.json | jq .
// request.json (remove this line from the actual file!)
{
"productType": "Hybrid Bicycle",
"createdAt": "Fri Jan 28 2022 03:13:24 GMT+0100 (GMT+02:00)",
"vendor": "Audi",
"totalInventory": 2,
"availableForSale": false,
"priceRange": {
"minPrice": {
"currencyCode": "USD",
"amount": 1160
},
"maxPrice": {
"currencyCode": "USD",
"amount": 1624
}
},
"description": "Autem ipsam quasi omnis ut. Et officiis quia. Sed quaerat pariatur nihil nobis est quos earum quidem.",
"title": "Hybrid Bicycle Sentra",
"id": "4139c5ae-b83d-4a0c-9b75-12d182aaed7c",
"handle": "hybrid-bicycle-sentra"
}
export TOKEN=<TOKEN> # replace <TOKEN> with the token from /api/user
curl -X PUT -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" http://localhost:3000/bikes/<ID> -d @request.json | jq . # replace <ID> with an ID from the response to /all
Updating and Deleting (Authentication required!)
// request.json (remove this line from the actual file!)
{
"totalInventory": 4,
"availableForSale": true
}
export TOKEN=<TOKEN> # replace <TOKEN> with the token from /api/user
curl -X PATCH -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" http://localhost:3000/bikes/<ID> -d @request.json | jq . # replace <ID> with an ID from the response to /all
export TOKEN=<TOKEN> # replace <TOKEN> with the token from /api/user
curl -X DELETE -H "Authorization: Bearer $TOKEN" http://localhost:3000/bikes/<ID> | jq . # replace <ID> with an ID from the response to /all
Get bearer authentication token:
curl -H 'Content-Type: application/json' http://localhost:3000/api/user -d '{"username": "cyclic"}' | jq .token -r