Skip to content

Commit

Permalink
Merge branch 'main' into gnanariddhika
Browse files Browse the repository at this point in the history
  • Loading branch information
panwar8279 authored Jun 10, 2024
2 parents 00a845e + 89c97ec commit 6900f27
Show file tree
Hide file tree
Showing 26 changed files with 630 additions and 216 deletions.
49 changes: 32 additions & 17 deletions backend/src/controllers/openSourceController.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,46 @@ require("dotenv").config();

const addProject = async (req, res) => {
try {
const {projectName, ownerUsername, tags, link, description} = req.body;
const { projectName, ownerUsername, tags, link, description } = req.body;

// Validation
if (!projectName || !ownerUsername || !link || !description) {
return res.status(400).json({ success: false, errors: ["All fields are required"] });
}

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

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

return res.status(201).json({ success: true });
}
catch (error) {
console.log(error);
if (!newProject) {
return res.status(401).json({ success: false, errors: ["Issue Adding the Tool"] });
}

return res.status(201).json({ success: true, project: newProject });
} catch (error) {
console.error(error);
return res.status(500).json({ success: false, errors: ["Internal Server Error"] });
}
}
};

const fetchAllProjects = async (req, res) => {
try {
const openSourceProjects = await OpenSource.find();
return res.status(200).json({ success: true, openSourceProjects: openSourceProjects });
}
catch (error) {
console.log(error);
const { page = 1, limit = 10 } = req.query;
const openSourceProjects = await OpenSource.find()
.skip((page - 1) * limit)
.limit(limit);

const totalProjects = await OpenSource.countDocuments();
return res.status(200).json({
success: true,
openSourceProjects,
totalPages: Math.ceil(totalProjects / limit),
currentPage: parseInt(page)
});
} catch (error) {
console.error(error);
return res.status(500).json({ success: false, errors: ["Internal Server Error"] });
}
}
};

module.exports = { addProject, fetchAllProjects };
module.exports = { addProject, fetchAllProjects };
164 changes: 27 additions & 137 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"antd": "^5.6.4",
"aos": "^2.3.4",
"axios": "^1.7.2",
Expand All @@ -18,10 +20,10 @@
"lottie-react": "^2.4.0",
"mongodb": "^6.2.0",
"pagination": "^0.4.6",
"react": "^18.2.0",
"react": "^18.3.1",
"react-accessible-accordion": "^5.0.0",
"react-chatbot-kit": "^2.2.2",
"react-dom": "^18.2.0",
"react-dom": "^18.3.1",
"react-hot-toast": "^2.4.1",
"react-icons": "^4.12.0",
"react-paginate": "^8.2.0",
Expand Down
Binary file added frontend/public/webflow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6900f27

Please sign in to comment.