Skip to content

Commit 52f1240

Browse files
committed
I added the auto-scroll feature and updated the readme
1 parent ecdbb1d commit 52f1240

1,171 files changed

Lines changed: 122573 additions & 8 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

chat-app/.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"liveServer.settings.port": 5501
3+
}

chat-app/README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ https://sdc.codeyourfuture.io/decomposition/sprints/2/prep/
77
You must complete and deploy a chat application. You have two weeks to complete this.
88

99
It must support at least the following requirements:
10-
* As a user, I can send add a message to the chat.
11-
* As a user, when I open the chat I see the messages that have been sent by any user.
12-
* As a user, when someone sends a message, it gets added to what I see.
10+
11+
- As a user, I can send add a message to the chat.
12+
- As a user, when I open the chat I see the messages that have been sent by any user.
13+
- As a user, when someone sends a message, it gets added to what I see.
1314

1415
It must also support at least one additional feature.
1516

@@ -27,8 +28,12 @@ Exploring and understanding different ways of sending information between a clie
2728

2829
### How to submit
2930

30-
* Fork the Module-Decomposition repository
31-
* Develop and deploy your chat app
32-
* Create a pull request back into the original Module-Decomposition repo, including:
33-
* A link to the deployed frontend on the CYF hosting environment
34-
* A link to the deployed backend on the CYF hosting environment
31+
- Fork the Module-Decomposition repository
32+
- Develop and deploy your chat app
33+
- Create a pull request back into the original Module-Decomposition repo, including:
34+
- A link to the deployed frontend on the CYF hosting environment
35+
- A link to the deployed backend on the CYF hosting environment
36+
37+
### Additional Feature
38+
39+
Auto‑scroll: The chat automatically scrolls to the newest message when messages load.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import express from "express";
2+
import cors from "cors";
3+
4+
const app = express();
5+
const PORT = 3000;
6+
7+
app.use(express.json());
8+
app.use(cors());
9+
10+
const messages = [];
11+
12+
app.get("/messages", (req, res) => {
13+
res.json(messages);
14+
});
15+
16+
app.post("/messages", (req, res) => {
17+
const { username, text } = req.body;
18+
const message = { username, text, timeStamp: new Date().toISOString() };
19+
messages.push(message);
20+
res.status(201).json(message);
21+
});
22+
23+
app.listen(PORT, () => {
24+
console.log(`Server is running on port ${PORT}`);
25+
});

0 commit comments

Comments
 (0)