Skip to content

Commit

Permalink
Merge pull request #2263 from AKSHITHA-CHILUKA/patch-14
Browse files Browse the repository at this point in the history
Update openSourceController.js
  • Loading branch information
panwar8279 authored Aug 3, 2024
2 parents d337617 + 480efb7 commit da015fb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions backend/src/controllers/openSourceController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ const addProject = async (req, res) => {
return res.status(400).json({ success: false, errors: ["All fields are required"] });
}

const newProject = await OpenSource.create({
const newProject = new OpenSource({
projectName, ownerUsername, tags, link, description
});

if (!newProject) {
return res.status(401).json({ success: false, errors: ["Issue Adding the Tool"] });
}
await newProject.save();

return res.status(201).json({ success: true, project: newProject });
} catch (error) {
Expand All @@ -28,11 +26,13 @@ const addProject = async (req, res) => {
const fetchAllProjects = async (req, res) => {
try {
const { page = 1, limit = 10 } = req.query;

const openSourceProjects = await OpenSource.find()
.skip((page - 1) * limit)
.limit(limit);
.limit(parseInt(limit));

const totalProjects = await OpenSource.countDocuments();

return res.status(200).json({
success: true,
openSourceProjects,
Expand Down

0 comments on commit da015fb

Please sign in to comment.