-
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
Showing
30 changed files
with
2,958 additions
and
1,686 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 |
---|---|---|
@@ -1,2 +0,0 @@ | ||
# Bloomia_app | ||
C:\Users\Faraz\Desktop\Bloomia_app\public\uploads\1633780506772defaultImage.jpg | ||
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,33 @@ | ||
require("./config/dbConfig"); | ||
require("dotenv").config(); | ||
require("express-async-errors"); | ||
|
||
const cors = require("cors"); | ||
const morgan = require("morgan"); | ||
const express = require("express"); | ||
const PORT = process.env.PORT || 3000; | ||
|
||
//routes | ||
const userRouters = require("./employee/employee.router"); | ||
const leadsRouters = require("./leads/leads.router"); | ||
const middleware = require("./utils/middleware"); | ||
|
||
const app = express(); | ||
|
||
//middlewears | ||
app.use(cors()); | ||
app.use(express.json()); | ||
app.use(morgan("dev")); | ||
app.use(express.static("public")); | ||
app.use(express.urlencoded({ extended: false })); | ||
|
||
app.use("/users", userRouters); | ||
app.use("/leads", leadsRouters); | ||
|
||
//errroHandelers | ||
app.use(middleware.unknownEndpoint); | ||
app.use(middleware.errorHandler); | ||
|
||
app.listen(PORT, () => { | ||
console.log(`SERVER IS WORKING AT PORT ${PORT}...`); | ||
}); |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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
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
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,34 @@ | ||
const mongoose = require("mongoose"); | ||
const EmployeeSchema = new mongoose.Schema( | ||
{ | ||
first_name: { | ||
type: String, | ||
}, | ||
last_name: { | ||
type: String, | ||
}, | ||
profileImage: { | ||
type: String, | ||
}, | ||
contact: { | ||
type: Number, | ||
}, | ||
email: { | ||
type: String, | ||
required: true, | ||
unique: true, | ||
}, | ||
password: { | ||
type: String, | ||
required: true, | ||
}, | ||
isVerified: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
{ timestamps: true } | ||
); | ||
|
||
const User = mongoose.model("employee", EmployeeSchema); | ||
module.exports = User; |
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,24 @@ | ||
const express = require("express"); | ||
// const upload = require("../middleware/multer"); | ||
const { authenticateToken } = require("../utils/jwt"); | ||
const router = express.Router(); | ||
const userController = require("./employee.controller"); | ||
|
||
// API for Employee register. | ||
router.post("/signup", async (req, res) => { | ||
const result = await userController.createUser(req); | ||
return res.send(result); | ||
}); | ||
|
||
// API for Employee login. | ||
router.post("/login", async (req, res) => { | ||
const result = await userController.loginUser(req); | ||
return res.json(result); | ||
}); | ||
|
||
router.get("/getUser", authenticateToken, async (request, response) => { | ||
const result = await userController.getUser(request); | ||
return response.json(result); | ||
}); | ||
|
||
module.exports = router; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,83 @@ | ||
const leadsDataAccess = require("./leads.dal"); | ||
const ExpressError = require("../utils/errorGenerator"); | ||
require("../utils/jwt"); | ||
exports.getAllLeads = async (req) => { | ||
const goal = await leadsDataAccess.findLeads(); | ||
return { | ||
error: false, | ||
sucess: true, | ||
message: "Get leads data", | ||
data: goal, | ||
}; | ||
}; | ||
exports.getUnclaimedLeads = async (req) => { | ||
const goal = await leadsDataAccess.findUnclaimedLeads(); | ||
return { | ||
error: false, | ||
sucess: true, | ||
message: "Get leads data", | ||
data: goal, | ||
}; | ||
}; | ||
|
||
exports.getClaimedLeadsByEmployee = async (req) => { | ||
const userId = req.token_data._id; | ||
console.log(userId) | ||
const goal = await leadsDataAccess.findClaimedLeadsByEmployee({ | ||
claimedUser: userId, | ||
}); | ||
return { | ||
error: false, | ||
sucess: true, | ||
message: "Get leads data", | ||
data: goal, | ||
}; | ||
}; | ||
exports.createForm = async (req) => { | ||
const { email, name, interestedCourse } = req.body; | ||
if (!name || !email || !interestedCourse) { | ||
throw new ExpressError(401, "Bad request"); | ||
} | ||
const data = { | ||
name: req.body.name, | ||
email: req.body.email, | ||
interestedCourse: req.body.interestedCourse, | ||
}; | ||
const lead = await leadsDataAccess.createLeads(data); | ||
return { | ||
error: false, | ||
sucess: true, | ||
message: "Get user data", | ||
data: lead, | ||
}; | ||
}; | ||
exports.claimLead = async (req) => { | ||
const { leadId } = req.params; | ||
if (!leadId) { | ||
throw new ExpressError(401, "Bad request"); | ||
} | ||
const userId = req.token_data._id; | ||
|
||
const updateData = { | ||
leadId, | ||
toUpdate: { | ||
isClaimed: true, | ||
claimedUser: userId, | ||
}, | ||
}; | ||
console.log(updateData) | ||
const update = await leadsDataAccess.claimLead(updateData); | ||
if (!update) { | ||
return { | ||
error: true, | ||
sucess: false, | ||
message: "user goal-set successfully", | ||
}; | ||
} | ||
return { | ||
error: false, | ||
sucess: true, | ||
message: "claimed successfully!", | ||
data: update, | ||
}; | ||
}; |
Oops, something went wrong.