-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit f2b0c9d
Showing
132 changed files
with
24,148 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,23 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
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,10 @@ | ||
const mongoose = require('mongoose'); | ||
const mongoURL = "mongodb://localhost:27017/FarmConnect?"; | ||
|
||
// const mongoURL = "mongodb://192.168.0.106:27017/FarmConnect?"; //IP address | ||
|
||
const connectToMongo = () => { | ||
mongoose.connect(mongoURL) | ||
}; | ||
|
||
module.exports = connectToMongo; |
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,31 @@ | ||
const connectToMongo = require('./db'); | ||
const express = require('express') | ||
const cors = require('cors') | ||
const path = require('path') | ||
const multer = require('multer') | ||
|
||
connectToMongo(); | ||
const app = express() | ||
const port = 5000 | ||
|
||
// Enabling cors for all routes | ||
app.use(cors()) | ||
|
||
// Setting up public as a static folder | ||
app.use(express.static(path.join(__dirname,'public'))) | ||
|
||
// Available Routes are divided into seperate files for each cateory of routes | ||
app.use('/api/supplierauth', require('./routes/supplierauth')) | ||
app.use('/api/farmerauth', require('./routes/farmerauth')) | ||
app.use('/api/buyerauth', require('./routes/buyerauth')) | ||
app.use('/api/supplieritem', require('./routes/supplieritem')) | ||
app.use('/api/farmeritem', require('./routes/farmeritem')) | ||
|
||
// '/' of backend (testing purposes) | ||
app.get("/",(req,res)=>{ | ||
res.json("FarmConnect backend is Farming.... Let him cook...") | ||
}) | ||
|
||
app.listen(port, () => { | ||
console.log(`Listening at http://localhost:${port}`) | ||
}) |
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,23 @@ | ||
const jwt = require('jsonwebtoken') | ||
|
||
const JWT_SECRET = "ImBatman"; | ||
|
||
const fetchbuyer = (req,res,next) =>{ | ||
let success = false | ||
|
||
// Fetching the buyer from auth-token | ||
const token = req.header('auth-token'); | ||
if(!token){ | ||
return res.status(400).send({error:"Authenticate using a valid token", success}); | ||
} | ||
|
||
try{ | ||
const data = jwt.verify(token, JWT_SECRET); | ||
req.buyer = data.buyer; | ||
next(); | ||
}catch(error){ | ||
return res.status(401).json({error:error}); | ||
} | ||
} | ||
|
||
module.exports = fetchbuyer; |
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,23 @@ | ||
const jwt = require('jsonwebtoken') | ||
|
||
const JWT_SECRET = "ImBatman"; | ||
|
||
const fetchfarmer = (req,res,next) =>{ | ||
let success = false | ||
|
||
// Fetching the farmer from auth-token | ||
const token = req.header('auth-token'); | ||
if(!token){ | ||
return res.status(400).send({error:"Authenticate using a valid token", success}); | ||
} | ||
|
||
try{ | ||
const data = jwt.verify(token, JWT_SECRET); | ||
req.farmer = data.farmer; | ||
next(); | ||
}catch(error){ | ||
return res.status(401).json({error:error}); | ||
} | ||
} | ||
|
||
module.exports = fetchfarmer; |
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,23 @@ | ||
const jwt = require('jsonwebtoken') | ||
|
||
const JWT_SECRET = "ImBatman"; | ||
|
||
const fetchsupplier = (req,res,next) =>{ | ||
let success = false | ||
|
||
// Fetching the supplier from auth-token | ||
const token = req.header('auth-token'); | ||
if(!token){ | ||
return res.status(400).send({error:"Authenticate using a valid token", success}); | ||
} | ||
|
||
try{ | ||
const data = jwt.verify(token, JWT_SECRET); | ||
req.supplier = data.supplier; | ||
next(); | ||
}catch(error){ | ||
return res.status(401).json({error:error}); | ||
} | ||
} | ||
|
||
module.exports = fetchsupplier; |
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,30 @@ | ||
const mongoose = require('mongoose'); | ||
const { Schema } = mongoose; | ||
|
||
// This is the model for 'buyer' | ||
const BuyerSchema = new Schema({ | ||
name: { | ||
type: String, | ||
required: true | ||
}, | ||
email: { | ||
type: String, | ||
required: true | ||
}, | ||
password:{ | ||
type: String, | ||
required: true | ||
}, | ||
location:{ | ||
type: String, | ||
// required: true | ||
}, | ||
profileimg:{ | ||
type: String, | ||
default: "pfp_blank.png" | ||
} | ||
}); | ||
|
||
const Buyer = mongoose.model('buyer', BuyerSchema); | ||
Buyer.createIndexes(); | ||
module.exports = Buyer; |
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,36 @@ | ||
const mongoose = require('mongoose'); | ||
const { Schema } = mongoose; | ||
|
||
// This is the model for 'farmer' | ||
const FarmerSchema = new Schema({ | ||
name: { | ||
type: String, | ||
required: true | ||
}, | ||
email: { | ||
type: String, | ||
required: true | ||
}, | ||
password:{ | ||
type: String, | ||
required: true | ||
}, | ||
location:{ | ||
type: String, | ||
// required: true | ||
}, | ||
address:{ | ||
type: String, | ||
}, | ||
phno:{ | ||
type:Number, | ||
}, | ||
profileimg:{ | ||
type: String, | ||
default: "pfp_blank.png" | ||
} | ||
}); | ||
|
||
const Farmer = mongoose.model('farmer', FarmerSchema); | ||
Farmer.createIndexes(); | ||
module.exports = Farmer; |
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,45 @@ | ||
const mongoose = require('mongoose'); | ||
const { Schema } = mongoose; | ||
|
||
// This is the model for 'farmer items' | ||
const FarmerItemSchema = new Schema({ | ||
farmer:{ | ||
type:mongoose.Schema.Types.ObjectId, | ||
required:true | ||
}, | ||
name:{ | ||
type:String, | ||
required:true | ||
}, | ||
description:{ | ||
type:String, | ||
required:true | ||
}, | ||
date:{ | ||
type: Date, | ||
default: Date.now() | ||
}, | ||
manuDate: { | ||
type: Date, | ||
required: true | ||
}, | ||
mrp: { | ||
type: Number, | ||
required: true | ||
}, | ||
sp: { | ||
type: Number, | ||
required: true | ||
}, | ||
itemImg: { | ||
type: String, | ||
default: "buyershop/default.png" | ||
}, | ||
tags: { | ||
type: [String] | ||
} | ||
}) | ||
|
||
const FarmerItem = mongoose.model('farmeritem', FarmerItemSchema); | ||
FarmerItem.createIndexes(); | ||
module.exports = FarmerItem; |
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,36 @@ | ||
const mongoose = require('mongoose'); | ||
const { Schema } = mongoose; | ||
|
||
// This is the model for 'supplier' | ||
const SupplierSchema = new Schema({ | ||
name: { | ||
type: String, | ||
required: true | ||
}, | ||
email: { | ||
type: String, | ||
required: true | ||
}, | ||
password:{ | ||
type: String, | ||
required: true | ||
}, | ||
location:{ | ||
type: String, | ||
// required: true | ||
}, | ||
address:{ | ||
type: String, | ||
}, | ||
phno:{ | ||
type:Number, | ||
}, | ||
profileimg:{ | ||
type: String, | ||
default: "pfp_blank.png" | ||
} | ||
}); | ||
|
||
const Supplier = mongoose.model('supplier', SupplierSchema); | ||
Supplier.createIndexes(); | ||
module.exports = Supplier; |
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,45 @@ | ||
const mongoose = require('mongoose'); | ||
const { Schema } = mongoose; | ||
|
||
// This is the model for 'supplier items' | ||
const SupplierItemSchema = new Schema({ | ||
supplier: { | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: 'supplier' | ||
}, | ||
name: { | ||
type: String, | ||
required: true | ||
}, | ||
description: { | ||
type: String, | ||
required: true | ||
}, | ||
date:{ | ||
type: Date, | ||
default: Date.now() | ||
}, | ||
manuDate: { | ||
type: Date, | ||
required: true | ||
}, | ||
mrp: { | ||
type: Number, | ||
required: true | ||
}, | ||
sp: { | ||
type: Number, | ||
require: true | ||
}, | ||
itemImg: { | ||
type: String, | ||
default: "buyershop/default.png" | ||
}, | ||
tags: { | ||
type: [String] | ||
} | ||
}) | ||
|
||
const SupplierItem = mongoose.model('supplieritem', SupplierItemSchema); | ||
SupplierItem.createIndexes(); | ||
module.exports = SupplierItem; |
Oops, something went wrong.