-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,640 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import commentHelper from '../helpers/commentHelper'; | ||
|
||
/** | ||
* reset password middleware | ||
* @author Kabalisa fiston | ||
* @class | ||
* @classdesc Comments | ||
*/ | ||
class Comments { | ||
/** | ||
* @function addComment | ||
* @param {Object} req | ||
* @param {Object} res | ||
* @returns {Object} Object with the type of comment created and time | ||
* range between the last comment | ||
*/ | ||
static async addComment(req, res) { | ||
const result = await commentHelper.createComment(req); | ||
return res.status(201).send(result); | ||
} | ||
|
||
/** | ||
* @function getComments | ||
* @param {Object} req | ||
* @param {Object} res | ||
* @returns {Object} Object with all comments on an article and their author | ||
*/ | ||
static async getComments(req, res) { | ||
const allComments = await commentHelper.getComments(req); | ||
return res.status(200).send({ comments: allComments }); | ||
} | ||
|
||
/** | ||
* @function getOneComment | ||
* @param {Object} req | ||
* @param {Object} res | ||
* @returns {Object} Object with one comment on an article and its author | ||
*/ | ||
static async getOneComment(req, res) { | ||
const oneComment = await commentHelper.getOneComment(req); | ||
return res.status(200).send({ comment: oneComment }); | ||
} | ||
|
||
/** | ||
* @function deleteOneComment | ||
* @param {Object} req | ||
* @param {Object} res | ||
* @returns {Object} Object with one comment on an article and its author | ||
*/ | ||
static async deleteOneComment(req, res) { | ||
const result = await commentHelper.deleteOneComment(req); | ||
return res.status(200).send(result); | ||
} | ||
|
||
/** | ||
* @function updateOneComment | ||
* @param {Object} req | ||
* @param {Object} res | ||
* @returns {Object} Object with one comment on an article and its author | ||
*/ | ||
static async updateOneComment(req, res) { | ||
const result = await commentHelper.updateOneComment(req); | ||
return res.status(201).send(result); | ||
} | ||
|
||
/** | ||
* @function replyComment | ||
* @param {Object} req | ||
* @param {Object} res | ||
* @returns {Object} Object with the type of comment created and time | ||
* range between the last comment | ||
*/ | ||
static async replyComment(req, res) { | ||
const result = await commentHelper.replyComment(req); | ||
const replycomment = result.toJSON(); | ||
return res.status(201).send(replycomment); | ||
} | ||
|
||
/** | ||
* @function getCommentReplies | ||
* @param {Object} req | ||
* @param {Object} res | ||
* @returns {Object} Object with all replies on a comment and the comment | ||
*/ | ||
static async getCommentReplies(req, res) { | ||
const result = await commentHelper.getCommentReplies(req); | ||
return res.status(200).send(result); | ||
} | ||
|
||
/** | ||
* @function deleteOneReply | ||
* @param {Object} req | ||
* @param {Object} res | ||
* @returns {Object} Object with one comment on an article and its author | ||
*/ | ||
static async deleteOneReply(req, res) { | ||
const result = await commentHelper.deleteOneReply(req); | ||
return res.status(200).send(result); | ||
} | ||
|
||
/** | ||
* @function updateOneReply | ||
* @param {Object} req | ||
* @param {Object} res | ||
* @returns {Object} Object with one comment on an article and its author | ||
*/ | ||
static async updateOneReply(req, res) { | ||
const result = await commentHelper.updateOneReply(req); | ||
return res.status(201).send(result); | ||
} | ||
} | ||
|
||
export default Comments; |
Oops, something went wrong.