Skip to content

Commit

Permalink
fixed some shitty codes created by some shitty developers
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy-py committed May 28, 2024
1 parent 4f2da03 commit c80f8f5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
8 changes: 6 additions & 2 deletions controllers/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,17 @@ exports.create = asyncHandler(async (req, res, next) => {

await session.commitTransaction();
session.endSession();
res.status(201).json({
return res.status(201).json({
success: true,
data: data
});
} catch (error) {
session.endSession();
next(error);
return res.status(500).json({
status: 'error',
message: 'Unable to create job',
error: error
});
}
});

Expand Down
29 changes: 21 additions & 8 deletions controllers/recruiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,18 +500,31 @@ exports.updateUserPI = asyncHandler(async (req, res, next) => {
});

/**
* @author Cyril ogoh <cyrilogoh@gmail.com>
* @description Get User Saved Jobs `Candidate Account Only`
* @route `/api/v1/candidate/jobs`
* @author Timothy <adeyeyetimothy33@gmail.com>
* @description Get all jobs by a recruiter`
* @route `/api/v1/rcruiter/jobs'
* @access Private
* @type GET
*/
exports.getJobs = asyncHandler(async (req, res, next) => {
const data = await Jobs.find({ _id: { $in: req.user.jobs } });
res.status(200).json({
success: true,
data: data
});
try {
const userId = req.user.id;
const jobs = await Jobs.find({
_author: userId
});

return res.status(200).json({
status: 'success',
message: 'Jobs retrieved successfully',
data: jobs
});
} catch (error) {
return res.status(500).json({
status: 'error',
message: 'Unable to retrieve jobs',
error: error
});
}
});

/**
Expand Down

0 comments on commit c80f8f5

Please sign in to comment.