Index Js (Front)
Index Js (Front)
const {
User,
Company,
College,
Candidate,
SkillTest,
CareerObjective,
CoverLetter,
MockInterview,
Vacancy,
State,
City,
Qualification,
Industry,
Courses
} = require("../../models");
const bcrypt = require("bcryptjs");
const router = [Link]();
const {
bucketName,
accessKeyId,
secretAccessKey,
region,
mimetypes,
bucketURL
} = require("../../../config");
const CompanyExecutive = require("../../models/companyExecutive");
const collegeRepresentative = require("../../models/collegeRepresentative");
const { generatePassword, sendMail } = require("../../../helpers");
const { Translate } = require('@google-cloud/translate').v2;
const { translateProjectId, translateKey } = require('../../../config')
rePath = [Link](`${[Link]}/front`, {
recentJobs, allQualification, allIndustry, allStates, data,
totalPages, page,
});
} catch (err) {
const ipAddress = [Link]('x-forwarded-for') ||
[Link];
[Link]('======================> 1', ipAddress, [Link]?.mobile,
[Link]?.name, err)
[Link]("error", [Link] || "Something went wrong!");
// return [Link]("back");
}
});
});
});
rePath = [Link](`${[Link]}/front/jobsearch`, {
});
});
[Link]("/jobsearch", (req, res) => {
const {body}=[Link];
rePath = [Link](`${[Link]}/front/jobsearch`, {
});
});
[Link]("/courses", async (req, res) => {
let filter = { status: true}
const countJobs = await [Link](filter).countDocuments()
const perPage = 9;
const p = parseInt([Link]);
const page = p || 1;
const totalPages = [Link](countJobs / perPage);
let courses = await [Link](filter).sort({ createdAt: -
1 }).skip(perPage * page - perPage).limit(perPage)
rePath = [Link](`${[Link]}/front/courses`, {
courses,
totalPages,
page
});
});
[Link]("/coursedetails/:id", async(req, res) => {
const {id}=[Link]
let course=await [Link]({_id:id})
rePath = [Link](`${[Link]}/front/coursedetails`, {
course
});
});
[Link]("/contact", (req, res) => {
rePath = [Link](`${[Link]}/front/contact`, {
});
});
[Link]("/contactt", (req, res) => {
rePath = [Link](`${[Link]}/front/contactUs`, {
});
});
[Link]("/sampleVideoProfile", (req, res) => {
rePath = [Link](`${[Link]}/front/sampleVideoProfile`, {
});
});
[Link]("/coursedetailmore", (req, res) => {
[Link]('=========== reached')
rePath = [Link](`${[Link]}/front/coursedetailmore`, {
});
});
[Link]("/jobdetailsmore/:jobId", async(req, res) => {
try{
[Link]('=======================> reached here')
let jobId = [Link]
if (jobId && ) {
throw [Link]("Invalid Job Id");
}
const populate = [
{
path: '_company',
select: "name logo stateId cityId mediaGallery
mediaGalaryVideo"
},
{
path: "_industry",
select: "name",
},
{
path: "_jobCategory",
select: "name",
},
{
path: "_qualification",
select: "name",
},
{
path: "state",
select: "name",
},
{
path: "city",
select: "name",
},
{
path: "_techSkills",
select: "name",
},
{
path: "_nonTechSkills",
select: "name",
},
];
const job = await [Link]({ _id:
jobId }).populate(populate)
let state = '';
let city = '';
if (job._company?.stateId && job._company?.cityId) {
state = await [Link]({ _id: job._company.stateId,
status: true })
city = await [Link]({ _id: job._company.cityId,
status: true, stateId: job._company.stateId })
}
const recentJobs = await [Link]({ status: true, _id: { $ne:
jobId } }).populate([
{
path: '_company',
select: "name logo"
},
{
path: "city",
select: "name",
}]).sort({ createdAt: -1 }).limit(5)
rePath = [Link](`${[Link]}/front/jobdetailmore`, {
job, recentJobs, state, city
});
}catch(err){
[Link](err,'err>>>>>>>>>>>>')
}
});
[Link]("/contact", (req, res) => {
rePath = [Link](`${[Link]}/front/contact`, {
});
});
[Link]("/jobdetails/:jobId", async (req, res) => {
try {
let jobId = [Link] //63d8cb2e421777708eaed0d8
if (jobId && ) {
throw [Link]("Invalid Job Id");
}
const populate = [
{
path: '_company',
select: "name logo stateId cityId mediaGallery
mediaGalaryVideo"
},
{
path: "_industry",
select: "name",
},
{
path: "_jobCategory",
select: "name",
},
{
path: "_qualification",
select: "name",
},
{
path: "state",
select: "name",
},
{
path: "city",
select: "name",
},
{
path: "_techSkills",
select: "name",
},
{
path: "_nonTechSkills",
select: "name",
},
];
const job = await [Link]({ _id: jobId }).populate(populate)
let state = '';
let city = '';
if (job._company?.stateId && job._company?.cityId) {
state = await [Link]({ _id: job._company.stateId, status:
true })
city = await [Link]({ _id: job._company.cityId, status:
true, stateId: job._company.stateId })
}
const recentJobs = await [Link]({ status: true, _id: { $ne: jobId
} }).populate([
{
path
: '_company',
select: "name logo"
},
{
path: "city",
select: "name",
}]).sort({ createdAt: -1 }).limit(5)
if ()
throw [Link]("Enter a valid password");
if (user) {
if ([Link] === 10 || [Link] === 0) {
let userData = { role: [Link], name: [Link],
_id: user._id, email: [Link] }
[Link] = userData;
return [Link]("/admin");
}
}
} catch (err) {
[Link]("error", [Link] || "Something went wrong!");
return [Link]("back");
}
});
if ([Link] == "company") {
const user0 = await [Link](
{ _company: data._id },
updata
);
}
if ([Link] == "college") {
// [Link]("innn", data);
const user1 = await [Link](
{
_college: data._id,
},
updata
);
}
//[Link](user1, "seconndddd");
}
return [Link](data);
} catch (err) {
[Link]("error", "Something went wrong!");
return [Link]("back");
}
});
if ([Link] == "company") {
// [Link]("[Link] = ", data._id);
const user3 = await [Link]({ _id:
[Link] });
}
if ([Link] == "candidate") {
// [Link]("[Link] = ", data._id);
const user3 = await [Link]({ _id: [Link]
});
}
if ([Link] == "skillTest") {
// [Link]("[Link] = ", data._id);
const user3 = await [Link]({ _id: [Link]
});
}
if ([Link] == "careerObjective") {
// [Link]("[Link] = ", data._id);
const user3 = await [Link]({
_id: [Link],
});
}
if ([Link] == "coverLetter") {
// [Link]("[Link] = ", data._id);
const user3 = await [Link]({ _id:
[Link] });
}
if ([Link] == "mockInterview") {
// [Link]("[Link] = ", data._id);
const user3 = await [Link]({
_id: [Link],
});
}
if ([Link] == "vacancy") {
// [Link]("[Link] = ", data._id);
const user3 = await [Link]({ _id:
[Link] });
}
return [Link](data);
} catch (err) {
[Link]("error", "Something went wrong!");
return [Link]("back");
}
});
//forget password
router
.route("/admin/forgotpassword")
.get(async (req, res) => {
rePath = [Link](`${[Link]}/front/forPass`);
return rePath;
})
.post(async (req, res) => {
try {
const email = [Link];
const tempPassword = await generatePassword();
const userData = await [Link]({ email: email });
if (!userData)
throw [Link](
"Invalid email, please enter your registered email"
);
<p style="line-height:32px;font-size:18px!important;font-
family:'Manrope',sans-serif!important">
Hi ${[Link]},<br/><br/>
<p style="line-height:32px;font-size:18px!important;font-
family:'Manrope',sans-serif!important">
Thank you,<br/>
</p>
</td>
</tr>
<tr>
<td style="font-family:
'manrope',sans-serif!important;text-align:left">
<ul style="list-style-
type: none;padding-left: 0px;margin: 20px 50px!important;">
<li style="padding-
top:0px">
<span
style="line-height:32px;font-size:18px!important;font-family:'Manrope',sans-serif!
important">
Sincerely,
<br/> Focalyt Group
</span>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
`;
[Link](
"success",
"Your new password has been sent to your registered email.
Please check your email."
);
[Link]("/admin/forgotpassword");
} catch (err) {
[Link]("error", [Link] || "Something went wrong!");
return [Link]("back");
}
});
//change password
router
.route("/admin/changepassword")
.get(async (req, res) => {
rePath = [Link](`${[Link]}/admin/setting/changePass`, { menu:
'dashboard' });
// rePath = [Link](`${[Link]}/front/login`);
return rePath;
})
.post(async (req, res) => {
try {
const newpassword = [Link];
const oldpassword = [Link];
const confirmpassword = [Link];
if () {
throw [Link]("Old password is incorrect!");
}
//edit profile
router
.route("/admin/editprofile")
.get(async (req, res) => {
var user = [Link];
rePath = [Link](`${[Link]}/admin/setting/editProfile`, {
user,
menu: 'dashboard'
});
// rePath = [Link](`${[Link]}/front/login`);
return rePath;
})
.post(async (req, res) => {
try {
const email = [Link];
const name = [Link];
var id = [Link]._id;
[Link]('/about')
.get(async (req, res) => {
rePath = [Link](`${[Link]}/front/about`, {
});
})
[Link]('/about-us')
.get(async (req, res) => {
rePath = [Link](`${[Link]}/front/aboutUs`, {
});
})
[Link]('/termsandconditions')
.get(async (req, res) => {
rePath = [Link](`${[Link]}/front/termsAndConditions`, {
});
})
[Link]('/privacy-policy')
.get(async (req, res) => {
rePath = [Link](`${[Link]}/front/privacyPolicy`, {
});
})
[Link]('/return-and-refund-policy')
.get(async (req, res) => {
rePath = [Link](`${[Link]}/front/returnAndRefundPolicy`, {
});
})
[Link]('/contact-us')
.get(async (req, res) => {
rePath = [Link](`${[Link]}/front/contactUs`, {
});
})
[Link]('/signs')
.get(async (req, res) => {
[Link]('X-FRAME-OPTIONS', 'ALLOW-FROM *');
[Link]('Content-Security-Policy', "frame-ancestors *");
rePath = [Link](`${[Link]}/front/signs`, {
});
})
[Link]('/signConverter')
.get(async (req, res) => {
[Link]('X-FRAME-OPTIONS', 'ALLOW-FROM *');
[Link]('Content-Security-Policy', "frame-ancestors *");
rePath = [Link](`${[Link]}/front/signConverter`, {
});
})
[Link]('/voice')
.get(async (req, res) => {
[Link]('X-FRAME-OPTIONS', 'ALLOW-FROM *');
[Link]('Content-Security-Policy', "frame-ancestors *");
rePath = [Link](`${[Link]}/front/voice`, {
});
})
[Link]('/translate')
.post(async (req, res) => {
[Link]('X-FRAME-OPTIONS', 'ALLOW-FROM *');
[Link]('Content-Security-Policy', "frame-ancestors *");
const lang = [Link] ? [Link] : 'hi'
const message = [Link]?.toLowerCase();
[Link]('I received this message ', message)
const translate = new Translate({ projectId: translateProjectId, key:
translateKey });
})
[Link]('/parser')
.get(async (req, res) => {
[Link]('X-FRAME-OPTIONS', 'ALLOW-FROM *');
[Link]('Content-Security-Policy', "frame-ancestors *");
rePath = [Link](`${[Link]}/front/parser`, {
});
})
[Link] = router;