This is a RESTful API built using Node.js and Express.js for managing products in an inventory system. The API supports basic CRUD (Create, Read, Update, Delete) operations for products and provides validation middleware to ensure data consistency.
Server deployed on : https://distributedlocking.onrender.com
- Add a new product: POST
/products
- Get a list of all products: GET
/products?query=query&page=1&limit=2
- Get details of a single product by ID: GET
/products/:id
- Update an existing product: PUT
/products/:id
- Delete a product by ID: DELETE
/products/:id
-
Clone the repository:
git clone [email protected]:CS-parth/DistributedLocking.git cd Arthalfa
-
Install the required dependencies:
npm install
-
Set up your environment variables:
Create a
.env
file in the root of the project and add the following:PORT=8989 DATABASE_URL=postgres://yourusername:yourpassword@yourhost:5432/yourdbname
Replace the values with your actual database credentials.
-
Start the server:
npm run start
The server will run on
http://localhost:8989
.
HTTP Method | Endpoint | Description |
---|---|---|
POST |
https://distributedlocking.onrender.com/products |
Add a new product |
GET |
https://distributedlocking.onrender.com/products |
Get a list of all products |
GET |
https://distributedlocking.onrender.com/products/:id |
Get details of a single product by ID |
PUT |
https://distributedlocking.onrender.com/products/:id |
Update an existing product by ID |
DELETE |
https://distributedlocking.onrender.com/products/:id |
Delete a product by ID |
For the POST and PUT requests, ensure to send the following fields in the request body:
POST on https://distributedlocking.onrender.com/products
{
"name": "CSparth",
"price": "99",
"description": "A product by CS",
"category": "Omniscient"
}