feat(site): implement site status API #143

Merged
fuzzy merged 1 commit from feat/site-status-api into main 2026-08-03 07:44:05 +00:00
Owner

What

Implement the site status and deployment history endpoints:

  • GET /api/v1/sites/{name} (#76) — returns a SiteStatus (the site plus its current deployment, i.e. newest deployment; current_deployment omitted when none exists). 404 for unknown sites.
  • GET /api/v1/sites/{name}/deployments (#77) — returns the deployment history, newest first. 404 for unknown sites.

SiteService gains:

  • Status(ctx, siteName) (*SiteStatus, error)sites.Getdeployments.ListBySite (newest first) → first entry as current deployment
  • Deployments(ctx, siteName) ([]Deployment, error) — 404 via sites.Get, then deployments.ListBySite

httpapi registers the two GET routes on the existing sites handler; both return 200 on success and 404 for unknown sites.

Why

Phase 5 task #78 — completes the HTTP Server and API phase; these endpoints let operators inspect a site's deployment state.

Testing

  • go build ./...
  • go vet ./...
  • go test -race ./... — 6 new site service tests (status with/without deployment, unknown site; history ordering, unknown site) + 4 handler tests; full suite passes
  • gofmt -l ./cmd ./internal ./pkg clean
  • golangci-lint run — 0 issues
  • pre-commit hooks all pass

Breaking Changes

None.

Notes

  • SiteStatus embeds Site with an optional CurrentDeployment.
  • Issues #76–#78 were closed via the Forgejo API as part of this task per the workflow.
  • Phase 5 (HTTP Server and API) is now complete.

Closes #76
Closes #77
Closes #78

## What Implement the site status and deployment history endpoints: - **`GET /api/v1/sites/{name}` (#76)** — returns a `SiteStatus` (the site plus its current deployment, i.e. newest deployment; `current_deployment` omitted when none exists). `404` for unknown sites. - **`GET /api/v1/sites/{name}/deployments` (#77)** — returns the deployment history, newest first. `404` for unknown sites. **`SiteService`** gains: - `Status(ctx, siteName) (*SiteStatus, error)` — `sites.Get` → `deployments.ListBySite` (newest first) → first entry as current deployment - `Deployments(ctx, siteName) ([]Deployment, error)` — 404 via `sites.Get`, then `deployments.ListBySite` **`httpapi`** registers the two GET routes on the existing sites handler; both return `200` on success and `404` for unknown sites. ## Why Phase 5 task #78 — completes the HTTP Server and API phase; these endpoints let operators inspect a site's deployment state. ## Testing - [x] `go build ./...` - [x] `go vet ./...` - [x] `go test -race ./...` — 6 new site service tests (status with/without deployment, unknown site; history ordering, unknown site) + 4 handler tests; full suite passes - [x] `gofmt -l ./cmd ./internal ./pkg` clean - [x] `golangci-lint run` — 0 issues - [x] pre-commit hooks all pass ## Breaking Changes None. ## Notes - `SiteStatus` embeds `Site` with an optional `CurrentDeployment`. - Issues #76–#78 were closed via the Forgejo API as part of this task per the workflow. - Phase 5 (HTTP Server and API) is now complete. Closes #76 Closes #77 Closes #78
feat(site): implement site status API
All checks were successful
Test and Release / lint (pull_request) Successful in 7m9s
Test and Release / test (pull_request) Successful in 7m20s
7281689095
Add read endpoints for site status and deployment history:

- SiteService.Status returns the site with its current (newest)
  deployment, or ErrNotFound for unknown sites
- SiteService.Deployments returns the deployment history for a site,
  newest first, or ErrNotFound for unknown sites
- httpapi registers GET /api/v1/sites/:name and
  GET /api/v1/sites/:name/deployments, returning 200 on success and
  404 for unknown sites

Add unit tests for status (with/without deployment, unknown site) and
deployment history (ordering, unknown site), plus handler tests.
Mark task done in ROADMAP.md.

closes #76
closes #77
closes #78
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-08-03 07:37:15 +00:00
the.auditor left a comment

Review Summary

Verified locally on the PR head (7281689): go build, go vet, gofmt, golangci-lint run all clean; full suite passes with -race (6 new service tests + 4 handler tests).

Clean, correct implementation. Status composes sites.Get + deployments.ListBySite (newest first) with the first entry as CurrentDeployment (omitted when none), and Deployments preserves the 404-on-unknown-site semantics. The embedded-Site SiteStatus serializes flat with the optional current_deployment field, and the gin routes (/api/v1/sites/:name and /api/v1/sites/:name/deployments) don't conflict with the existing POST /api/v1/sites. Handlers map ErrNotFound → 404 correctly.

No blocking issues.

Non-blocking observations:

  1. "Current deployment" = newest by DeployedAt; since Publish stamps time.Now(), this is sound today, but a distinct active/status flag will be needed once failed/pending states exist (Phase 6/7).
  2. These GET endpoints are unauthenticated, consistent with registration — all covered by the Phase 9 auth middleware task.

Approving.

## Review Summary Verified locally on the PR head (`7281689`): `go build`, `go vet`, `gofmt`, `golangci-lint run` all clean; full suite passes with `-race` (6 new service tests + 4 handler tests). Clean, correct implementation. `Status` composes `sites.Get` + `deployments.ListBySite` (newest first) with the first entry as `CurrentDeployment` (omitted when none), and `Deployments` preserves the 404-on-unknown-site semantics. The embedded-`Site` `SiteStatus` serializes flat with the optional `current_deployment` field, and the gin routes (`/api/v1/sites/:name` and `/api/v1/sites/:name/deployments`) don't conflict with the existing `POST /api/v1/sites`. Handlers map `ErrNotFound` → 404 correctly. **No blocking issues.** Non-blocking observations: 1. "Current deployment" = newest by `DeployedAt`; since `Publish` stamps `time.Now()`, this is sound today, but a distinct active/status flag will be needed once failed/pending states exist (Phase 6/7). 2. These GET endpoints are unauthenticated, consistent with registration — all covered by the Phase 9 auth middleware task. Approving.
fuzzy merged commit 7281689095 into main 2026-08-03 07:44:05 +00:00
fuzzy deleted branch feat/site-status-api 2026-08-03 07:44:05 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/thwap-pagesd!143
No description provided.