Skip to content

Commit

Permalink
make add project data function
Browse files Browse the repository at this point in the history
relates #24
  • Loading branch information
MohammedAlghazali committed Mar 30, 2020
1 parent 90d683a commit 70a78ac
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/controllers/routes/admin/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const router = require('express').Router();
const { cohortDelete } = require('./cohort');
const { validateAddProject } = require('./project');
const { cohortAdd, validateAddProject } = require('./project');

router
.route('/cohorts/:cohortId')
Expand All @@ -20,6 +20,6 @@ router
})
.delete(cohortDelete);

router.post('/projects', validateAddProject);
router.post('/projects', validateAddProject, cohortAdd);

module.exports = router;
34 changes: 34 additions & 0 deletions server/controllers/routes/admin/project/addProject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const addProject = require('../../../../database/queries/project/addProject');

const cohortAdd = async (req, res, next) => {
try {
const {
name,
description,
imgUrl,
githubLink,
websiteLink,
projectType,
cohortId,
} = req.body;
await addProject(
name,
description,
imgUrl,
githubLink,
websiteLink,
projectType,
cohortId,
);
res.json({
StatusCode: 200,
data: { message: 'Cohort Added successfully' },
});
} catch (err) {
next(err);
}
};

module.exports = {
cohortAdd,
};

0 comments on commit 70a78ac

Please sign in to comment.