Skip to content

NW | 26-SDC-Mar | Zabihollah Namazi | Sprint 2 | Chat App frontend#77

Open
ZabihollahNamazi wants to merge 11 commits into
CodeYourFuture:mainfrom
ZabihollahNamazi:zabihollah-chat-app
Open

NW | 26-SDC-Mar | Zabihollah Namazi | Sprint 2 | Chat App frontend#77
ZabihollahNamazi wants to merge 11 commits into
CodeYourFuture:mainfrom
ZabihollahNamazi:zabihollah-chat-app

Conversation

@ZabihollahNamazi
Copy link
Copy Markdown

@ZabihollahNamazi ZabihollahNamazi commented May 4, 2026

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

could you please check my pr ? thank you very much

@github-actions

This comment has been minimized.

@ZabihollahNamazi ZabihollahNamazi added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Decomposition The name of the module. labels May 4, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label May 4, 2026
@github-actions

This comment has been minimized.

@ZabihollahNamazi ZabihollahNamazi changed the title Norht West | 26-SDC-Mar | Zabihollah Namazi | chat app North West | 26-SDC-Mar | Zabihollah Namazi | Sprint 2 | chat app May 4, 2026
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@ZabihollahNamazi ZabihollahNamazi changed the title North West | 26-SDC-Mar | Zabihollah Namazi | Sprint 2 | chat app NW | 2026-mar-sdc | Zabihollah Namazi | Module-Decomposition | Sprint 2 | chat-app May 4, 2026
@github-actions

This comment has been minimized.

@ZabihollahNamazi ZabihollahNamazi added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels May 4, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label May 4, 2026
@github-actions

This comment has been minimized.

@ZabihollahNamazi ZabihollahNamazi changed the title NW | 2026-mar-sdc | Zabihollah Namazi | Module-Decomposition | Sprint 2 | chat-app Manchester | 26-SDC-Mar | Zabihollah Namazi | Sprint 2 | Chat App frontend May 4, 2026
@github-actions

This comment has been minimized.

@ZabihollahNamazi ZabihollahNamazi changed the title Manchester | 26-SDC-Mar | Zabihollah Namazi | Sprint 2 | Chat App frontend NW | 26-SDC-Mar | Zabihollah Namazi | Sprint 2 | Chat App frontend May 4, 2026
@ZabihollahNamazi ZabihollahNamazi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label May 4, 2026
@ZabihollahNamazi
Copy link
Copy Markdown
Author

Copy link
Copy Markdown

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code works on normal circumstances. My comments are mainly surrounding handling of
errors and unusual user input.


Can you also include these items in the PR description?

  • A description of the additional features you have implemented
  • A link to the deployed frontend on the CYF hosting environment
  • A link to the deployed backend on the CYF hosting environment

Comment thread chat-app/frontend/app.js
document.addEventListener("DOMContentLoaded", () => {
const messagesList = document.getElementById("messages-list");
const form = document.getElementById("message-form");
const input = document.getElementById("message-input");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can you make this named constant more meaningful?

Comment thread chat-app/frontend/app.js
Comment on lines +10 to +11
const res = await fetch(BACKEND_URL);
const messages = await res.json();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if any of the operations fails?

Comment thread chat-app/frontend/app.js
Comment on lines +17 to +21
li.innerHTML = `
<div><strong>${msg.username}</strong></div>
<div>${msg.text}</div>
<small>${msg.timeStamp}</small>
`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently HTML injection is possible. Can you update the code or propose a solution to prevent it from happening?

Comment thread chat-app/frontend/app.js
Comment on lines +29 to +36
await fetch(BACKEND_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
username: usernameInput.value,
text: input.value,
}),
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • No input sanitization and validation ?

  • What if the operation fails or return a "username and text required" error response?

Comment on lines +19 to +23
const { username, text } = req.body;

if (!username || !text) {
return res.status(400).json({ error: "username and text required" });
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good practice to validate all request inputs.

A more robust implementation should also account for potential failures on line 19 and include appropriate error handling.

In this exercise, let's assume the request is always coming from the code in script.js. So no change needed.

messages.push({
username,
text,
timeStamp: new Date().toLocaleTimeString(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you suggest a strategy to ensure that users in different time zones see timestamps in their respective local time zones?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Decomposition The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants