Skip to content

dsin867/example-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Products API (Demo)

API for managing products


Setup Instructions

  1. Clone the repository
    git clone https://github.com/dsin867/example-rest-api.git
    cd example-rest-api
  2. Install dependencies
    npm install
  3. Create a .env file at the root level Add your API key in the following format:
    API_KEY=example-key-1234
  4. Start the server
    node src/index.js

API Documentation

Base URL: /api/products

Endpoints

GET /api/products

  • Description: Retrieve all products.
  • Response: Array of product objects.

POST /api/products

  • Description: Create a new product.
  • Body:
    {
      "product_id": number,
      "name": string,
      "category": string,
      "price": number,
      "stockQuantity": number,
      "brand": string
    }
  • Response: Created product object.

PUT /api/products/:id

  • Description: Update an existing product by ID.
  • Body:
    {
      "name": string,
      "category": string,
      "price": number,
      "stockQuantity": number,
      "brand": string
    }
  • Response: Updated product object.

DELETE /api/products/:id

  • Description: Delete a product by ID.
  • Response: Success message or deleted product object.

Product Object Example

{
  "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"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published