https://github.com/alpha74/productscrud_nodejs
A simple CRUD app for Product table using Nodejs, ExpressJs, Mongoose
https://github.com/alpha74/productscrud_nodejs
Last synced: 10 months ago
JSON representation
A simple CRUD app for Product table using Nodejs, ExpressJs, Mongoose
- Host: GitHub
- URL: https://github.com/alpha74/productscrud_nodejs
- Owner: alpha74
- Created: 2023-04-25T10:34:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-26T11:27:44.000Z (over 2 years ago)
- Last Synced: 2025-01-16T04:41:24.472Z (12 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

## CRUD app for Products
- A simple CRUD operation APIs defined for model `Product`
- Using Nodejs, ExpressJs and Mongoose
### Run dev
- `npm run dev`
### Run prod
- `node server.js`
-----------
### APIs
- Response codes used are: `200 OK, 404 NOT FOUND, 500 INTERNAL SERVER ERROR`
#### Nudge server
- `GET /`
- Sample Request: `http://localhost:3000/`
- Response: `Hello`
-----------
#### Get single product detail
- `GET /products/`
- Sample Request:
```
GET http://localhost:3000/products/6447ab99bfe33111831d5880
```
- Sample Response
```
{
"name": "brush",
"quantity": 2,
"price": 50,
"image": "IMAGE_LINK",
"_id": "6447ab99bfe33111831d5880",
"createdAt": "2023-04-25T10:29:45.566Z",
"updatedAt": "2023-04-25T10:29:45.566Z",
"__v": 0
}
```
---------
#### Get all products list
- `GET /products`
- Sample Request
```
GET http://localhost:3000/products/
```
- Sample Response
```
[
{
"name": "brush",
"quantity": 2,
"price": 50,
"image": "IMAGE_LINK",
"_id": "6447ab99bfe33111831d5880",
"createdAt": "2023-04-25T10:29:45.566Z",
"updatedAt": "2023-04-25T10:29:45.566Z",
"__v": 0
},
{
"name": "brrom",
"quantity": 2,
"price": 50,
"image": "IMAGE_LINK",
"_id": "6447ab99bfe33111831d5880",
"createdAt": "2023-04-25T10:29:45.566Z",
"updatedAt": "2023-04-25T10:29:45.566Z",
"__v": 0
}
]
```
----------
#### Add new product
- `POST /products`
- Sample Request
```
POST http://localhost:3000/products/
JSON payload
{
"name" : "brush",
"quantity": 2,
"price" : 50,
"image" : "IMAGE_LINK"
}
```
- Sample Response:
```
{
"name": "brush",
"quantity": 2,
"price": 50,
"image": "IMAGE_LINK",
"_id": "6447ab99bfe33111831d5880",
"createdAt": "2023-04-25T10:29:45.566Z",
"updatedAt": "2023-04-25T10:29:45.566Z",
"__v": 0
}
```
---------------
#### Update Product
- `PUT /products/`
- Sample Request:
```
PUT http://localhost:3000/products/6447ab99bfe33111831d5880
JSON payload
{
"name" : "brush",
"quantity": 2,
"price" : 50,
"image" : "IMAGE_LINK"
}
```
- Sample Response
```
{
"name": "brush",
"quantity": 2,
"price": 50,
"image": "IMAGE_LINK",
"_id": "6447ab99bfe33111831d5880",
"createdAt": "2023-04-25T10:29:45.566Z",
"updatedAt": "2023-04-25T10:29:45.566Z",
"__v": 0
}
```
-----------
#### Delete a Product
- `DELETE /products`
- Sample Request:
```
DELETE http://localhost:3000/products/6447ab99bfe33111831d5880
```
- Sample Response:
```
{
"name": "brush",
"quantity": 2,
"price": 50,
"image": "IMAGE_LINK",
"_id": "6447ab99bfe33111831d5880",
"createdAt": "2023-04-25T10:29:45.566Z",
"updatedAt": "2023-04-25T10:29:45.566Z",
"__v": 0
}
```