Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/surajmendhe5573/remove-product-api
Remove Product API
https://github.com/surajmendhe5573/remove-product-api
Last synced: 6 days ago
JSON representation
Remove Product API
- Host: GitHub
- URL: https://github.com/surajmendhe5573/remove-product-api
- Owner: surajmendhe5573
- Created: 2024-08-16T15:30:45.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-16T15:59:17.000Z (3 months ago)
- Last Synced: 2024-08-16T17:23:10.624Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Product Management API
This is a Node.js and Express.js based API for managing products. The API allows users to create, restore, edit, and permanently delete products.
## Features
- Create new products
- Remove products
- Restore removed products (Put Back)
- Edit product details
- Permanently delete products.## API Endpoints
### Create a Product
- **URL**: `http://localhost:3000/api/products`
- **Method**: `POST`
- **Body**:
```json
{
"name": "Product Name",
"price": 100,
"description": "Product Description"
}```
- **Response**:
```json
{
"message": "Product created successfully",
"product": {
"_id": "product_id",
"name": "Product Name",
"price": 100,
"description": "Product Description",
"removed": false
}
}
```
```
```### Remove Product (Soft Delete)
- **URL**: `http://localhost:3000/api/products/:id/remove`
- **Method**: `POST`
- **Response**:
```
{
"message": "Product removed successfully"
}```
### Restore Product (Put Back)
- **URL**: `http://localhost:3000/api/products/:id/restore`
- **Method**: `POST`
- **Response**:
```
{
"message": "Product restored successfully"
}
```
```
### Edit Product- **URL**: `http://localhost:3000/api/products/:id/edit`
- **Method**: `POST`
- **Body**:
```json
{
"name": "Updated Product Name",
"price": 150,
"description": "Updated Product Description"
}```
### Permanently Delete Product- **URL**: `http://localhost:3000/api/products/:id/delete`
- **Method**: `DELETE`
- **Response**:
```
{
"message": "Product restored successfully"
}
```
```## Installation
### Prerequisites
- Node.js and npm installed.
- MongoDB running locally or on a cloud service like MongoDB Atlas.2. Install the dependencies:
```bash
npm install
```## Set Up Environment Variables
Create a `.env` file in the root directory of your project and add your environment variables. Below is an example `.env` file:
**Example `.env` file:**
```envPORT=3000
MONGO_URI=mongodb://localhost:27017/defaultdb