Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/surajmendhe5573/remove-products
https://github.com/surajmendhe5573/remove-products
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/surajmendhe5573/remove-products
- Owner: surajmendhe5573
- Created: 2024-08-16T13:06:00.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-16T13:16:37.000Z (3 months ago)
- Last Synced: 2024-08-16T14:37:48.029Z (3 months ago)
- Language: JavaScript
- Size: 14.6 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 Product**: Create a new product with name, description, price, and an option to display on the homepage.
- **Restore Product**: Restore a previously removed product.
- **Edit Product**: Update product details such as name, description, price, and display status.
- **Delete Product Permanently**: Permanently delete a product from the database.## API Endpoints
### Create a Product
- **URL**: `http://localhost:5000/api/products`
- **Method**: `POST`
- **Body**:
```json
{
"name": "Product Name",
"description": "Product Description",
"price": 1000,
"displayOnHomePage": true
}
```
- **Response**:
- `201 Created`: On success.
- `400 Bad Request`: If name or price is missing.### Restore a Product
- **URL**: `http://localhost:5000/api/products/:id/restore`
- **Method**: `PUT`
- **Body**:
```json
{
"displayOnHomePage": true
}
```
- **Response**:
- `200 OK`: On success.
- `404 Not Found`: If product ID does not exist.### Edit a Product
- **URL**: `http://localhost:5000/api/products/:id`
- **Method**: `PUT`
- **Body**:
```json
{
"name": "Updated Product Name",
"description": "Updated Description",
"price": 1200,
"displayOnHomePage": false
}
```
- **Response**:
- `200 OK`: On success.
- `404 Not Found`: If product ID does not exist.### Delete a Product Permanently
- **URL**: `http://localhost:5000/api/products/:id`
- **Method**: `DELETE`
- **Response**:
- `200 OK`: On success.
- `404 Not Found`: If product ID does not exist.## Installation
### Prerequisites
- Node.js and npm installed.
- MongoDB running locally or on a cloud service like MongoDB Atlas.### Steps
1. Clone the repository:
```bash
git clone https://github.com/surajmendhe5573/remove-products
```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=5000
MONGO_URI=mongodb://localhost:27017/defaultdb