File size: 578 Bytes
758abec
 
 
 
 
 
 
 
 
ebd1d0a
 
 
 
84c78f6
ebd1d0a
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
---
title: Chatroom
emoji: 🐨
colorFrom: red
colorTo: pink
sdk: docker
pinned: false
---

# Node.js 聊天室(无依赖)

这是一个最小可用的聊天室示例:服务端使用 Node.js 内置 `http`,消息推送使用 SSE(Server-Sent Events),不需要安装任何 npm 依赖。

## 本地运行

```bash
npm start
```

然后打开:

http://localhost:3000

## 接口

- `GET /events?username=xxx`:SSE 消息流(加入/离开/消息)
- `POST /message`:发送消息(JSON:`{ "username": "xx", "text": "hello" }`- `GET /healthz`:健康检查