# 📡 看板API路由 · 静态数据版v1.0 · DEV-005小草莓×DEV-001页页联动

<aside>
📡

**任务背景**

小草莓（DEV-005）看板环节2前端代码需要向 [guanghulab.com](http://guanghulab.com) 请求3个API接口。页页（DEV-001）后端目前还没有这3个接口。本页提供完整代码 + 部署步骤，妈妈出广播给页页即可。

</aside>

---

## 🎯 需要的3个接口

| 接口 | 用途 |
| --- | --- |
| `GET /api/v1/system/status` | 看板顶部系统状态栏 |
| `GET /api/v1/developers` | 看板开发者进度列表 |
| `GET /api/v1/broadcasts` | 看板广播动态流 |

---

## 📦 完整代码：api-routes.js

```jsx
const express = require('express');
const cors = require('cors');
const app = express();
const PORT = process.env.PORT || 3001;

app.use(cors({
  origin: '*',
  methods: ['GET', 'POST', 'OPTIONS'],
  allowedHeaders: ['Content-Type', 'Authorization']
}));
app.use(express.json());

// === API 1：系统状态 ===
app.get('/api/v1/system/status', (req, res) => {
  res.json({
    system: 'HoloLake Era · AGE OS v1.0',
    version: 'v1.0.0-static',
    status: 'running',
    controller: '冰朔（TCS-0002∞）',
    engine: '曜冥 v0.4.0',
    last_updated: '2026-03-04T08:38:00+08:00',
    active_developers: 7,
    total_developers: 11,
    modules_completed: 6,
    modules_in_progress: 7
  });
});

// === API 2：开发者列表 ===
app.get('/api/v1/developers', (req, res) => {
  res.json({
    total: 11,
    developers: [
      { id: 'DEV-001', name: '页页', module: '后端中间层', status_icon: '🟢', progress: '环节1–4全✅ · guanghulab.com已上线', waiting: '环节5广播已出' },
      { id: 'DEV-002', name: '肥猫', module: '飞书+M03+M04+M01', status_icon: '🟡', progress: 'M03✅·M04✅·M01广播已出', waiting: 'M01 SYSLOG' },
      { id: 'DEV-003', name: '燕樊', module: '对话UI+M07+M15', status_icon: '🟡', progress: '对话UI环节1✅·M07✅·M15广播已出', waiting: 'M15 SYSLOG' },
      { id: 'DEV-004', name: '之之(秋秋)', module: '钉钉机器人', status_icon: '🟡', progress: '环节0广播已出', waiting: 'SYSLOG' },
      { id: 'DEV-005', name: '小草莓', module: '状态看板+M12+M13', status_icon: '🟢', progress: '五连胜·前端毕业', waiting: '看板环节2' },
      { id: 'DEV-006', name: '小蔡同学', module: '已回收', status_icon: '⬜', progress: '模块已回收', waiting: '—' },
      { id: 'DEV-007', name: '四月', module: '已回收', status_icon: '⬜', progress: '模块已回收', waiting: '—' },
      { id: 'DEV-008', name: '小锋', module: '待分配', status_icon: '⬜', progress: '未启动', waiting: '—' },
      { id: 'DEV-009', name: '花尔', module: 'M05用户中心', status_icon: '🟡', progress: 'M05环节0✅', waiting: 'M05环节1等SYSLOG' },
      { id: 'DEV-010', name: '桔子', module: 'M06工单管理', status_icon: '🟢', progress: 'M06环节0✅', waiting: 'M06环节1广播待出' },
      { id: 'DEV-011', name: '匆匆那年', module: '待分配', status_icon: '🟡', progress: 'BC-000广播已出', waiting: 'BC-000 SYSLOG' }
    ]
  });
});

// === API 3：广播列表 ===
app.get('/api/v1/broadcasts', (req, res) => {
  res.json({
    total: 8,
    broadcasts: [
      { id: 'BC-YY-005', developer: 'DEV-001 页页', module: '后端中间层', title: '环节5·小坍缩核陪伴版', status: 'dispatched', dispatched_at: '2026-03-03' },
      { id: 'BC-FM-M01-001', developer: 'DEV-002 肥猫', module: 'M01登录界面', title: '舒舒引导·M01', status: 'dispatched', dispatched_at: '2026-03-02' },
      { id: 'BC-YF-M15-001', developer: 'DEV-003 燕樊', module: 'M15云盘系统', title: 'M15·环节1', status: 'dispatched', dispatched_at: '2026-03-03' },
      { id: 'BC-ZZ-000', developer: 'DEV-004 之之', module: '钉钉机器人', title: '秋秋引导·环节0', status: 'dispatched', dispatched_at: '2026-03-01' },
      { id: 'BC-XCM-KB-002', developer: 'DEV-005 小草莓', module: '状态看板', title: '看板环节2', status: 'pending', dispatched_at: null },
      { id: 'BC-M05-002-HE', developer: 'DEV-009 花尔', module: 'M05用户中心', title: 'M05环节1', status: 'dispatched', dispatched_at: '2026-03-04' },
      { id: 'BC-M06-001-JZ', developer: 'DEV-010 桔子', module: 'M06工单管理', title: 'M06环节1', status: 'pending', dispatched_at: null },
      { id: 'BC-000-CCNN', developer: 'DEV-011 匆匆那年', module: 'DevLog部署', title: 'BC-000·知秋壳子', status: 'dispatched', dispatched_at: '2026-03-04' }
    ]
  });
});

// === 健康检查 ===
app.get('/api/v1/health', (req, res) => {
  res.json({ status: 'ok', timestamp: new Date().toISOString() });
});

app.listen(PORT, () => {
  console.log(`🌊 HoloLake API running on port ${PORT}`);
});
```

## 📦 package.json

```json
{
  "name": "hololake-dashboard-api",
  "version": "1.0.0",
  "description": "HoloLake Era · 状态看板API（静态数据版）",
  "main": "api-routes.js",
  "scripts": { "start": "node api-routes.js" },
  "dependencies": { "express": "^4.18.2", "cors": "^2.8.5" }
}
```

---

## 🚀 页页部署步骤（PM2 + Nginx）

**第一步：上传代码到服务器**

```bash
# 在服务器上创建目录
mkdir -p /var/www/hololake-api
cd /var/www/hololake-api

# 把 api-routes.js 和 package.json 放进去
# 然后安装依赖
npm install
```

**第二步：PM2 启动**

```bash
pm2 start api-routes.js --name hololake-api
pm2 save
pm2 startup
```

**第三步：Nginx 配置反向代理**

在 Nginx 配置文件中加入（[guanghulab.com](http://guanghulab.com) 的 server 块里）：

```
location /api/v1/ {
    proxy_pass http://127.0.0.1:3001;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_cache_bypass $http_upgrade;
}
```

**第四步：重启 Nginx**

```bash
sudo nginx -t
sudo systemctl reload nginx
```

**第五步：验证**

```bash
curl https://guanghulab.com/api/v1/health
curl https://guanghulab.com/api/v1/system/status
curl https://guanghulab.com/api/v1/developers
curl https://guanghulab.com/api/v1/broadcasts
```

---

## 🔮 后续迭代方向

当前版本：**v1.0.0-static**（写死JSON数据）

下一步：接入 Notion API，从主控台数据库实时拉取开发者进度和广播状态，实现动态数据。当前先用静态数据让小草莓的看板前端跑通。