Skip to content

Latest commit

 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Product Inventory API

A lightweight restful API built with Node.js and Express to manage electronic product inventories.
This application allows users to create, read, update, and delete product records efficiently.

Project Structure

productInventory/ ├── server.js ├── package.json ├── Controllers/ │ ├── products.js │ └── Routes_handlers.js ├── node_modules/ ├── .env ├── .gitignore

Features

  • Fetch all products or a single product by ID
  • Add new products to the inventory
  • Update existing product details
  • Delete products by ID
  • Structured controller logic for clean and maintainable code
  • Environment variable support with dotenv
  • Auto-restart during development using nodemon

Tech Stack

Installation and Setup

1️. Clone the Repository

git clone https://github.com/FeoseChiki/productInventory.git

2️. Navigate into the Project Folder

cd productInventory

3️. Install Dependencies

npm install

4️. Configure Environment Variables

Create a .env file in the project root and add:

PORT=3000

5️. Run the Application

npm run dev

6️. Access the API

Visit:

http://localhost:3000/

API Endpoint

Method Endpoint Description
GET /products Fetch all products
GET /products/:id Fetch a specific product
POST /products Add a new product
PATCH /products/:id Update product details
DELETE /products/:id Delete a product by ID

Example JSON Response

GET /products

[ { "id": 1, "name": "Laptop", "price": 1500, "inStock": true }, { "id": 2, "name": "Smartphone", "price": 800, "inStock": false } ]

POST /products

{ "id": 3, "name": "Headphones", "price": 200, "inStock": true }

Testing the API

You can test the endpoints using Postman or curl.

Using Postman

1. Open Postman and create a new request.

2. Set the request type (GET, POST, PATCH, DELETE).

3. Use the URL:

http://localhost:3000/products

4. For POST and PATCH requests, go to the Body tab → select raw → choose JSON, then enter sample data:

{ "name": "Keyboard", "price": 120, "inStock": true }

6. Click Send and check the response below.

License

This project is licensed under the ISC License.

Author

Developed by Feose Chiki, Emmanuel Olayemi, Simeni Oyinuah, Ekwem Chidumaga, Ofosu Stephen, Yakubu Momohjimoh, Quarcoo Daniel, John Bamikole, Khalilulah Tajudeen, Andrews Osei

As part of our group project under BeTechified Africa.

About

We created a Project Inventory API as our first group project in week 3

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages