Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@

# Haikus for Codespaces

This is a quick node project template for demoing Codespaces. It is based on the [Azure node sample](https://github.com/Azure-Samples/nodejs-docs-hello-world). It's great!!!

Point your browser to [Quickstart for GitHub Codespaces](https://docs.github.com/en/codespaces/getting-started/quickstart) for a tour of using Codespaces with this repo.

## 如何執行測試

1. 安裝相依套件:

```bash
npm install
```

2. 執行整合測試:

```bash
npm test
```

目前測試會驗證:
- `GET /` 是否回傳 `200`。
- `GET /healthz` 是否回傳 `200` 與 `{ status: 'ok' }`。

## 健康檢查用途

此專案提供 `GET /healthz` 端點,回傳 `200` 與 JSON `{"status":"ok"}`。可用於:
- 平台健康檢查(例如 Kubernetes liveness/readiness probe)。
- 負載平衡器後端存活確認。
- 監控系統定期輪詢服務可用性。
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ app.get('/', (req, res) => {
res.render('index', {haikus: haikus});
});

app.listen(port);
app.get('/healthz', (req, res) => {
res.status(200).json({ status: 'ok' });
});

if (require.main === module) {
app.listen(port);
}

module.exports = app;
Loading