Files
Kokorone/scripts/smoke/A.mjs
Jeffery ae9c44dde7 feat: 完成 A 群組 — 專案骨架與可重啟的服務
- packages/shared:TypeScript 專案參考建置鏈路、統一日誌模組(Asia/Taipei 格式)
- apps/api:最小 NestJS 服務,GET /health
- apps/web:最小 Next.js(App Router + Tailwind v4)首頁,套用品牌色票與亮暗模式
- scripts/dev-restart.mjs:讀 .dev-pids 以 process group 訊號安全停止舊行程、背景啟動 api/web 並輪詢健康檢查
- scripts/smoke:npm run smoke -- <群組代號> 冒煙測試框架,A 群組測試涵蓋 /health 與首頁內容
- 本機 port 3000 被既有服務佔用,web 開發埠改為 3100(已記錄於 todo.md)

npm run restart && npm run smoke -- A 皆通過(A-V)。
2026-08-13 09:18:40 +08:00

23 lines
800 B
JavaScript

const API_PORT = process.env.PORT_API ?? "3001";
const WEB_PORT = process.env.PORT_WEB ?? "3100";
export default async function smokeA() {
const healthRes = await fetch(`http://localhost:${API_PORT}/health`);
if (healthRes.status !== 200) {
throw new Error(`GET /health 回傳 ${healthRes.status},預期 200`);
}
const healthBody = await healthRes.json();
if (healthBody.status !== "ok") {
throw new Error("GET /health 回應內容缺少 status: ok");
}
const homeRes = await fetch(`http://localhost:${WEB_PORT}/`);
if (homeRes.status !== 200) {
throw new Error(`web 首頁回傳 ${homeRes.status},預期 200`);
}
const homeHtml = await homeRes.text();
if (!homeHtml.includes("心音")) {
throw new Error("web 首頁內容缺少「心音」字樣");
}
}