London-9-Saghar-Hosseinmardi-Node-Coursework-Week2#272
London-9-Saghar-Hosseinmardi-Node-Coursework-Week2#272SagharHosseinmardi wants to merge 7 commits intoCodeYourFuture:masterfrom
Conversation
jonnywyatt
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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?