Skip to content

Commit

Permalink
#17 - plugin-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
chihab committed Feb 4, 2020
1 parent 22af185 commit 5348258
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 17 additions & 0 deletions back-end/server/controller/PluginController.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,21 @@ module.exports = {
res.json({status: "success", message: "Plugin added successfully!!!", data: null});
});
},

/**
* Rate a plugin given its id
*/
rate: (req, res, next) => {
console.log("ratePlugin");
console.log(req.body.pluginId);
console.log(req.body.note);

PluginModel.findByIdAndUpdate(req.body.pluginId, req.body.note, (err, result) => {
if(err){
next(err);
} else{
res.json({status: "success", message: `Plugin of id: ${req.body.pluginId} successfully rated: ${req.body.note}`, data: null});
}
});
},
};
7 changes: 5 additions & 2 deletions back-end/server/routes/PluginRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ module.exports = (Application) => {
Application.route('/plugins').post(Controller.PluginController.create);
Application.route('/plugins/:pluginId').get(Controller.PluginController.getById);
Application.route('/plugins/:pluginId').delete(Controller.PluginController.deleteById);
};

/**
* modify existing resource
*/
Application.route('/plugins/rate').post(Controller.PluginController.rate);
};

0 comments on commit 5348258

Please sign in to comment.