-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
445b5c2
commit c2c36ca
Showing
8 changed files
with
1,129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
|
||
# E-Commerce Product Provider API | ||
|
||
This API provides functionalities for managing products in an e-commerce platform. It supports creating, reading, updating, and deleting product information. | ||
|
||
## Features | ||
|
||
- Get and Build Our Projects. | ||
- Search for products by name, category, or other attributes | ||
- Pagination support for product listings | ||
- Authentication and authorization | ||
|
||
## Setup | ||
|
||
1. Navigate to the project directory: | ||
```bash | ||
cd e-commerce-product-provider-api | ||
``` | ||
2. Install dependencies: | ||
|
||
```bash | ||
npm install | ||
``` | ||
|
||
3. Set up environment variables: | ||
- Create a .env file in the root of the project and add the following variables: | ||
|
||
```env | ||
DB=Your_MONGODB_URL | ||
``` | ||
|
||
4. Run the Project | ||
|
||
```bash | ||
node index.js | ||
``` | ||
|
||
## Routes | ||
```js | ||
Routes:{ | ||
all_product:"/products", | ||
category:"/products/category/:category", | ||
specidic_product:"/products/product/:id" | ||
} | ||
``` | ||
|
||
## Methods | ||
|
||
```bash | ||
GET / | ||
GET /products/category/:category | ||
GET /products/product/:id | ||
``` | ||
|
||
## Output | ||
|
||
- **All Products** | ||
![Screenshot from 2024-07-21 21-49-42](https://github.com/user-attachments/assets/3f955ed3-1dd8-46ae-97d7-cd1ce3e0207c) | ||
|
||
- **Category** | ||
![Screenshot from 2024-07-21 21-50-39](https://github.com/user-attachments/assets/23ccbe33-355e-4279-bb30-6c46c2db8343) | ||
|
||
- **Specific Product** | ||
![Screenshot from 2024-07-21 21-51-49](https://github.com/user-attachments/assets/5a0feb6b-30b9-455b-874b-5a053b259882) | ||
|
||
|
||
## Contributing | ||
|
||
[Sivaprasath2004](https://github.com/sivaprasath2004) | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const express=require('express') | ||
const app=express() | ||
require('dotenv').config() | ||
const mongoose=require('mongoose') | ||
const products=require('./mongodb/shopping') | ||
const cors=require('cors') | ||
app.use(cors()) | ||
app.use(express.json()) | ||
app.use(express.urlencoded({extended:true})) | ||
app.get("/",(req,res)=>{res.send({ | ||
author:"sivaprasath2004", | ||
category:["mobile","laptop","toys","fashion","furniture"], | ||
Routes:{ | ||
all_product:"/products", | ||
category:"/products/category/:category", | ||
specidic_product:"/products/product/:id" | ||
} | ||
})}) | ||
app.get("/products",async(req,res)=>{ | ||
await mongoose.connect(process.env.DB) | ||
try{ | ||
let product=await products.find() | ||
res.send(product) | ||
throw new Error('Something went wrong!'); | ||
}catch(err){ | ||
res.send(err) | ||
} | ||
}) | ||
app.get("/products/category/:category",async(req,res)=>{ | ||
await mongoose.connect(process.env.DB) | ||
try{ | ||
let product=await products.find({category:req.params.category}) | ||
res.send(product) | ||
throw new Error('Something went wrong!'); | ||
}catch(err){ | ||
res.send(err) | ||
} | ||
}) | ||
app.get("/products/product/:id",async(req,res,next)=>{ | ||
await mongoose.connect(process.env.DB) | ||
try{ | ||
let product=await products.findById(req.params.id) | ||
if(product){ | ||
res.send(product) | ||
}else{res.send("Sorry no more products available")} | ||
throw new Error('Something went wrong!'); | ||
}catch(err){ | ||
res.send(err) | ||
} | ||
}) | ||
app.listen(5000,()=>{console.log("app listen in 5000")}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const mongoose=require('mongoose') | ||
const user_schema=new mongoose.Schema({ | ||
category:String, | ||
productName:String, | ||
brand:String, | ||
details:[{ | ||
'color':String, | ||
"material":String, | ||
"length": String, | ||
"display": String, | ||
}], | ||
camera:[{ | ||
front:String, | ||
back:String | ||
}], | ||
size:[String], | ||
battery:String, | ||
warrenty:String, | ||
img:[ | ||
{ | ||
url:String, | ||
caption:String | ||
}, | ||
{ | ||
url:String, | ||
caption:String | ||
} | ||
], | ||
cards:[ | ||
{ | ||
url:String, | ||
caption:String | ||
}, | ||
{ | ||
url:String, | ||
caption:String | ||
} | ||
], | ||
MRPprize:Number, | ||
SELLprize:Number, | ||
stock:String, | ||
}) | ||
module.exports=mongoose.model('users',user_schema) | ||
|
Oops, something went wrong.