Skip to content
This repository was archived by the owner on Aug 17, 2024. It is now read-only.

Conversation

@SagharHosseinmardi
Copy link

Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in HOW_TO_MARK.md in the root of this repository

Your Details

  • Your Name:
  • Your City:
  • Your Slack Name:

Homework Details

  • Module:
  • Week:

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?

  • Any other notes?

Copy link

@jonnywyatt jonnywyatt left a 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"

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();

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;

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) => {

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants