-
-
Notifications
You must be signed in to change notification settings - Fork 444
London-9-Saghar-Hosseinmardi-Node-Coursework-Week2 #272
base: master
Are you sure you want to change the base?
London-9-Saghar-Hosseinmardi-Node-Coursework-Week2 #272
Conversation
jonnywyatt
left a comment
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.
Well done! I've added some suggestions about storing date formats and naming endpoints.
| "scripts": { | ||
| "start": "node server.js" | ||
| "start": "node server.js", | ||
| "dev": "nodemon server.js" |
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.
the dev task is useful when developing locally on your laptop, do you know why?
| // message.timeSent = Date.now(); | ||
| // message.timeSent = new Date().toDateString(); | ||
| // message.timeSent = new Date().toISOString(); | ||
| message.timeSent = new Date().toString(); |
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 will store a date with the format "Tue Aug 19 1975 23:15:30" (link).
It's much better to store dates in ISO format using toISOString() (which you have commented above), so that the timezone offset is always standard as UTC; it's much less confusing.
| }); | ||
|
|
||
| app.get("/message/:id", (req, res) => { | ||
| const userId = req.params.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.
The ID is the message ID not the user ID so easier to understand if it's named that way.
| } | ||
| }); | ||
|
|
||
| app.put("/messages/update/:id", (req, res) => { |
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.
Typically you wouldn't have a verb 'update' in the URL. You'd just send a put to /messages/:id. This convention is called REST.
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.mdin the root of this repositoryYour Details
Homework Details
Notes
What did you find easy?
What did you find hard?
What do you still not understand?
Any other notes?