This project is a RESTful API built using Cloudflare Workers and Fauna. It manages a simple inventory with basic CRUD (Create, Read, Update, Delete) operations.
This code is part of a tutorial on Youtube.
- A Fauna account
- Cloudflare account
- Node 18 installed
Follow these steps to get the Inventory Management REST API up and running:
- Clone this repository
- Install dependencies:
npm install
- In your
wrangler.toml
file in the root directory add the following environment variables: -FAUNA_SECRET
: Your Fauna secret key - Deploy the project:
npm run deploy
You can use tools like Postman or CURL to test the API:
curl -X POST https://your-worker-url.xyz/ -H "Content-Type: application/json" -d '{"item": "Apple", "quantity": 10, "price": 2}'
curl -X GET "https://your-worker-url.xyz/"
curl -X GET "https://your-worker-url.xyz/?id=<some-id>"
curl -X PUT "https://your-worker-url.xyz/?id=<ID>" -H "Content-Type: application/json" -d '{"item": "Updated Apple", "quantity": 20, "price": 3}'
curl -X DELETE "https://your-worker-url.xyz/?id=<ID>"