Skip to content

feat(server): add GET /api/clubs endpoint (#44)#77

Merged
Sootopolis merged 1 commit into
mainfrom
wip
Jun 10, 2026
Merged

feat(server): add GET /api/clubs endpoint (#44)#77
Sootopolis merged 1 commit into
mainfrom
wip

Conversation

@Sootopolis

Copy link
Copy Markdown
Owner

What

Adds a lightweight read-only GET /api/clubs endpoint returning every non-tombstoned club as {slug, name}, alphabetical by slug:

{ "clubs": [ { "slug": "team-alpha", "name": "Team Alpha" } ] }

Source: Club.selectAll, filtering _stale_<id> tombstone rows and sorting by slug. Reuses the existing RouteHelpers.jsonResponse / withErrorHandling pattern (DB SQLException → logged 500, matching the other routes). Empty DB → {"clubs":[]}, 200.

Why

Completion-cache source for the CLI v0 epic (#40): the CLI writes the response to its clubs.txt cache to drive ccas <club> <TAB> completion. Unblocks #49 (shell completions). In Phase 2 this is superseded by /api/auth/me's managed_clubs[] (#66) — deferred there.

Also

Collapse the route assembly in CcasServer from a long ++ chain into a List(...).reduce(_ ++ _) so adding a route is a one-line change; annotated with the combined env so a new route's deps surface at compile time.

Tests

TestRoutes gains a ClubRoutes sub-suite: alphabetical ordering + _stale_ exclusion (with self-cleaning fixture) and the {clubs:[{slug,name}]} wire shape. Full suite green locally (785/785).

Closes #44.
Part of #40.

Lightweight read-only endpoint listing every non-tombstoned club as
{slug, name}, alphabetical by slug, so the CLI can populate its
shell-completion cache. Tombstoned _stale_<id> rows are excluded.

Also collapse the route assembly in CcasServer from a long ++ chain
into a List(...).reduce(_ ++ _) so adding a route is a one-line change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Sootopolis Sootopolis merged commit 6de507c into main Jun 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GET /api/clubs endpoint

1 participant