├── .gitignore ├── package.json ├── README.md └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | 3 | .env -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "smart-dhopa-server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js", 8 | "start:dev": "nodemon index.js", 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "body-parser": "^1.19.0", 15 | "cors": "^2.8.5", 16 | "dotenv": "^8.2.0", 17 | "express": "^4.17.1", 18 | "mongodb": "^3.6.3", 19 | "objectid": "^3.2.1" 20 | }, 21 | "devDependencies": { 22 | "nodemon": "^2.0.6" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Smart Dhopa 2 | 3 | Smart Dhopa is the first Online Laundry Platform in DIU with the latest technology in washing, dry cleaning and laundry. Our services combine our expertise and experience acquired over a period of time to provide you with clean laundry in the shortest possible turnaround time. 4 | 5 | [Live Website](https://smart-dhopa-online-laundry-app.web.app/) | [Live API Server](https://smart-dhopa-server.herokuapp.com/) 6 | 7 | ### Admin Dashboard 8 | 9 | ``` 10 | https://smart-dhopa-online-laundry-app.web.app/admin 11 | ``` 12 | 13 | ## Front-end Thechnology : 14 | 1. React.js 15 | 2. Matarial UI 16 | 3. ReactStrap 17 | 5. MDB & Now UI kit 18 | 4. Bootstrap4 19 | 5. SCSS 20 | 21 | ## Back-end Technology : 22 | 1. Node.js 23 | 2. Express.js 24 | 3. MongoDB 25 | 26 |
27 | 28 | > ### Install 29 | ``` 30 | npm install 31 | ``` 32 | > ### Build webpack 33 | ``` 34 | npm run build 35 | ``` 36 | > ### Dev Server 37 | 38 | ``` 39 | npm start 40 | ``` 41 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const MongoClient = require('mongodb').MongoClient; 3 | const bodyParser = require('body-parser'); 4 | const cors = require('cors'); 5 | require('dotenv').config(); 6 | const ObjectId = require('mongodb').ObjectId; 7 | 8 | const app = express(); 9 | app.use(cors()); 10 | app.use(bodyParser.json()); 11 | app.use(bodyParser.urlencoded({ extended: true })); 12 | const port = 4200; 13 | 14 | const uri = `mongodb+srv://${process.env.DB_USER}:${process.env.DB_PASS}@cluster0.v9ypd.mongodb.net/${process.env 15 | .DB_NAME}?retryWrites=true&w=majority`; 16 | 17 | const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true }); 18 | 19 | client.connect((err) => { 20 | const orders = client.db('smartDhopa').collection('order'); 21 | console.log('Orders connection successfully'); 22 | 23 | // Update Order Status 24 | app.post('/updateOrder', (req, res) => { 25 | const ap = req.body; 26 | orders.updateOne( 27 | { _id: ObjectId(ap.id) }, 28 | { 29 | $set: { status: ap.status, progress: ap.progress } 30 | }, 31 | (err, result) => { 32 | if (err) { 33 | console.log(err); 34 | res.status(500).send({ message: err }); 35 | } else { 36 | res.send(result.modifiedCount > 0); 37 | console.log(result); 38 | } 39 | } 40 | ); 41 | }); 42 | 43 | // Update Order details 44 | app.post('/updateOrderDetails', (req, res) => { 45 | const od = req.body; 46 | orders.updateOne( 47 | { _id: ObjectId(od.id) }, 48 | { 49 | $set: { shipment: od.shipment, products: od.products, price: od.price } 50 | }, 51 | (err, result) => { 52 | if (err) { 53 | console.log(err); 54 | res.status(500).send({ message: err }); 55 | } else { 56 | res.send(result.modifiedCount > 0); 57 | console.log(result); 58 | } 59 | } 60 | ); 61 | }); 62 | 63 | // Added Place Order 64 | app.post('/addOrders', (req, res) => { 65 | const newOrder = req.body; 66 | orders.insertOne(newOrder).then((result) => { 67 | res.send(result.insertedCount > 0); 68 | }); 69 | // console.log(newOrder); 70 | }); 71 | 72 | // Get specific user Orders 73 | app.get('/orders', (req, res) => { 74 | // console.log(req.query.email); 75 | orders.find({ email: req.query.email }).toArray((err, documents) => { 76 | res.send(documents); 77 | }); 78 | }); 79 | 80 | // Get all Orders 81 | app.get('/allOrders', (req, res) => { 82 | orders.find({}).toArray((err, documents) => { 83 | res.send(documents); 84 | }); 85 | }); 86 | 87 | 88 | }); 89 | 90 | client.connect((err) => { 91 | const products = client.db('smartDhopa').collection('products'); 92 | console.log('Products connection successfully'); 93 | 94 | // Update Product Information 95 | app.post('/updateProduct', (req, res) => { 96 | const pd = req.body; 97 | products.updateOne( 98 | { _id: ObjectId(pd.id) }, 99 | { 100 | $set: { name: pd.name, price: pd.price } 101 | }, 102 | (err, result) => { 103 | if (err) { 104 | console.log(err); 105 | res.status(500).send({ message: err }); 106 | } else { 107 | res.send(result.modifiedCount > 0); 108 | console.log(result); 109 | } 110 | } 111 | ); 112 | }); 113 | 114 | // Get all products 115 | app.get('/products', (req, res) => { 116 | products.find({}).toArray((err, documents) => { 117 | res.send(documents); 118 | }); 119 | }); 120 | 121 | // Add Products in inventory 122 | app.post('/addProducts', (req, res) => { 123 | const allProduct = req.body; 124 | products.insertOne(allProduct).then((result) => { 125 | console.log(result.insertedCount); 126 | res.send(result.insertedCount > 0); 127 | }); 128 | }); 129 | 130 | // Delete Product 131 | app.delete('/deleteProducts/:id', (req, res) => { 132 | console.log(req.params.id); 133 | 134 | products.deleteOne({ _id: ObjectId(req.params.id) }).then((result) => { 135 | res.send(result.deletedCount > 0); 136 | }); 137 | }); 138 | 139 | 140 | }); 141 | 142 | // Root Route 143 | app.get('/', (req, res) => { 144 | res.send('Welcome to Smart Dhopa'); 145 | }); 146 | 147 | // PORT 148 | app.listen(process.env.PORT || port, () => { 149 | console.log('listening on port'); 150 | }); 151 | --------------------------------------------------------------------------------