-
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
Vote for ideas #51
Vote for ideas #51
Conversation
use it to vote for comments
const { username } = req.auth; | ||
|
||
// what is the type of the object we vote for (i.e. ideas, comments, ...) | ||
const primarys = req.baseUrl.substring(1); |
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.
is there such a word?
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.
I doubt that. Do you have some alternative suggestions?
primary
is supposed to mean "object to which the vote belongs" and s
is supposed to mean plural of that.
Perhaps objectTypePlural
, typeVotedObjects
, votedCollectionsName
? Any other ideas?
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.
For me primarys can stay it doesn't make a confusion (just lingual one) and it is quite clear. I was mostly curious.
@@ -57,6 +57,9 @@ module.exports = function controllersFactory(primary) { | |||
* Middleware to read comments of a primary object (i.e. idea) | |||
*/ | |||
async function get(req, res, next) { | |||
|
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.
It is very nice to have this factory function for this.
return res.status(201).json(serializedVote); | ||
} catch (e) { | ||
// handle errors | ||
switch (e.code) { |
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.
Are we not returning any comment for those errors? Is it because it is boring to write or somehow unnecessary with the frontend?
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.
Added error response body.
To some extent the error codes are self-explanatory. You're right that it is boring to write (and test) and that some error info would actually be useful. I'll fix it.
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.
I was thinking more generally if there is any standard in ditup regarding this and what is the explanation.
Yes, it is quite clear what I am getting if there is 409 or 201, maybe some 400 validation explanation is useful (and that is double boring).
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.
- we are displaying validation errors as they're generated by
json-schema
- 404 errors can be confusing (is it a nonexistent path, or user or what?) and error messages can be useful.
- there are probably other errors with neglected but potentially useful error body reporting
} | ||
|
||
/** | ||
* Read a vote from user to multiple ideas or comments or something |
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.
I am curious when is it used, the function.
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.
When we want to find out whether user voted for a particular comment (to show the self vote). When there are i.e. 20 comments, we want to fetch all the user's voting info at once.
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.
Thank you.
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.
Very interesting.
Thank you @agatatalita for collaborating on this. 🙂 |
maybe change value of a vote(won't do now) (PATCH vote #52)