Skip to content

SRCthird/cs499-inventory-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CS499 Inventory API

A super simple Express + MongoDB REST API for managing inventory items.
Each item includes a name (item) and a storage location (location).

Features

  • CRUD Endpoints

    • GET /inventory — List all items with optional filtering, sorting, and pagination.
    • GET /inventory/:id — Retrieve a single item by ID.
    • POST /inventory — Create a new inventory item.
    • PUT /inventory/:id — Update an existing item.
    • DELETE /inventory/:id — Delete an item.
  • Input validation using a helper function (pickInventory).

  • Case-insensitive searching via MongoDB collation.

  • Duplicate prevention on item + location pairs.

  • Environment configuration via .env file.

Getting Started

1. Clone the repository

git clone https://github.com/srcthird/cs499-inventory-api.git
cd inventory-api

2. Install dependencies

npm install

3. Set up your environment file

Create a .env file in the project root:

HOST=0.0.0.0
PORT=3000
MONGODB_URI=mongodb://<credentials>@localhost:27017/CS499

4. Start the server

npm run dev

(or)

node dist/index.js

Example Request

Create a new item

POST /inventory
Content-Type: application/json

{
  "item": "Wrench",
  "location": "Tool Room"
}

Response

{
  "_id": "651abc1234...",
  "item": "Wrench",
  "location": "Tool Room"
}

Health Check

GET /health

Response

{ "ok": true }

About

cs499 inventory api

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published