- Clone the repository
git clone https://github.com/dsin867/example-rest-api.git cd example-rest-api
- Install dependencies
npm install
- Create a
.env
file at the root level Add your API key in the following format:API_KEY=example-key-1234
- Start the server
node src/index.js
Base URL: /api/products
- Description: Retrieve all products.
- Response: Array of product objects.
- Description: Create a new product.
- Body:
{ "product_id": number, "name": string, "category": string, "price": number, "stockQuantity": number, "brand": string }
- Response: Created product object.
- Description: Update an existing product by ID.
- Body:
{ "name": string, "category": string, "price": number, "stockQuantity": number, "brand": string }
- Response: Updated product object.
- Description: Delete a product by ID.
- Response: Success message or deleted product object.
{
"product_id": 1,
"created_at": "2024-12-12 04:21:45",
"isActive": true,
"name": "Product 1",
"category": "Category",
"price": 99.99,
"stockQuantity": 10,
"brand": "BrandA"
}