-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#168781692 add and view comment #40
Conversation
20bd930
to
51ed07e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job Eric. Kindly change the message that you return when posting a comment and make it comment-related. I think the user is posting a comment not updating a request. Other than that, well done.
1f56e94
to
472f294
Compare
static async addComment(req, res) { | ||
const { comment } = req.body; | ||
const { id } = req.user.payload; | ||
const requestId = parseInt(req.params.id, 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line here
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line
try { | ||
const requestId = parseInt(req.params.id, 10); | ||
const comments = await models.comments.findAll({ | ||
where: { requestId } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets all comments on a request even the soft deleted ones. Add a condition to get comments only when the deleted= false
src/middlewares/commentMiddleware.js
Outdated
|
||
const { requests, users } = models; | ||
|
||
const commentMiddle = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get this a better name please
src/routes/api/comments.js
Outdated
import commentMiddleware from '../../middlewares/commentMiddleware'; | ||
|
||
const router = new Router(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line
src/routes/api/comments.js
Outdated
const router = new Router(); | ||
|
||
const { addComment, getComments } = commentsController; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line
const { addComment, getComments } = commentsController; | ||
|
||
const { validateComment } = InputValidation; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line
chai.use(chaiHttp); | ||
|
||
const id = mockdata.verifiedUser1.id; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line
return res.send(error); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ngireric123 good job. Kindly work on the feedback below.
- Return the user object you can return
id, username and email
when retrieving comments - Add your endpoints to swagger
- Check out the comments I have left on the pr
- create one endpoint for add/ view comment - create one controller for changeStatus - create a helper for comment - create a routes for API [starts #168781692]
472f294
to
eac722b
Compare
What does this PR do?
Description of Task to be completed?
How should this be manually tested?
npm install
sequelize db:migrate
sequelize db:seed:all
npm run dev
Any background context you want to provide?
To add a comment
POST
request tohttp://localhost:<:port>/api/v1/comments/:id
To view a comment
GET
request tohttp://localhost:<:port>/api/v1/comments/:id
What are the relevant pivotal tracker stories?
#168781692
Screenshots (if appropriate)
Questions:
N/A