Repository navigation
Conversation
- Added backend with Express server and message handling routes - Implemented message sending, fetching, and reacting functionalities - Created frontend HTML structure for chat interface - Developed JavaScript for message rendering and user interactions - Styled chat application with CSS for better user experience
- Added package.json for backend with necessary dependencies (express, cors, crypto). - Implemented server.js for handling message retrieval, sending, and reactions with long-polling support. - Created index.html for the frontend chat interface with a message input area and display for chat messages. - Developed script.js to manage message fetching, sending, and user interactions (like, dislike, reply). - Styled the chat application with style.css for a user-friendly interface.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
3 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
LonMcGregor
left a comment
There was a problem hiding this comment.
Good start on this task, apologies for the late review.
I've spotted a couple of areas you could look at again, see my comments below.
|
|
||
| if (req.username) { | ||
| res.send( | ||
| `You are authenticated as ${req.username}.\n\n` + |
There was a problem hiding this comment.
Given these messages are quite similar, could you rework the if block to reduce the code duplication?
There was a problem hiding this comment.
Agreed the response text was duplicated. I’ve refactored it so only the authentication message is conditional, and the shared subject information is sent once. Thanks for the suggestion. @LonMcGregor
| next(); | ||
| } | ||
|
|
||
| app.use(express.json()); |
There was a problem hiding this comment.
Does express.json() do all of the checks you did in your original code?
There was a problem hiding this comment.
express.json() handles parsing and malformed JSON, but it doesn’t validate the expected structure. I’ve added a middleware after it that checks the body is an array of strings and returns 400 if it isn’t.Thanks @LonMcGregor
LonMcGregor
left a comment
There was a problem hiding this comment.
Great, this task is complete now
Learners, PR Template
Self checklist
CYF-1165
wrote two new middleware demonstrating Express middleware.