Welcome to your simple & magical RESTful API built with Express.js!
Manage your product list stored in a JSON file — perfect for learning all those CRUD moves! 💃🕺
- 📦 Get all products
- 🔍 Get a product by ID
- 🆕 Create a new product
- 🔄 Update an existing product
- ❌ Delete a product
- 🚨 Validation with friendly error messages
- 💾 Data saved in a local JSON file (
data/products.json) - 🌐 CORS enabled for cross-origin requests ✨
- Clone the repo
git clone https://github.com/your-username/express-live-server-demo.git
cd express-live-server-demo- Install dependencies
npm install- Start the server
npm run devServer runs on 👉 http://localhost:3000
GET /productsReturns an array of all products.
GET /products/:id
- id (number) - the product ID
Returns the product object or 404 if not found.
POST /products
Content-Type: application/json
{
"title": "Magic Mushroom Lamp",
"price": 19.99,
"description": "A glowing little friend for cozy nights."
}Returns 201 Created with the new product or 400 on validation error.
PUT /products/:id
Content-Type: application/json
{
"title": "New title", // optional
"price": 15.00, // optional
"description": "New desc" // optional
}Returns 200 OK with updated product or 400/404 errors.
DELETE /products/:idReturns 200 OK with deletion confirmation or 404 if not found.
- 📃 title: required, must be a non-empty string
- 💸 price: required, must be a finite positive number
- 📄 description: required, must be a non-empty string
Test all API endpoints with the included Thunder Client collection!
- File: thunder_client/thunder-collection_ProductAPI.json
- How to use:
- Open Thunder Client extension in VS Code
- Click Import
- Select the JSON file above
- Run requests and watch the magic happen! ✨
- 💾 Move to a real database (MongoDB, MySQL, etc.)
- 🔐 Add authentication & authorization
- 🛠️ Better error handling & logging
MIT © Rainy