Skip to content

refactor(api): unify ROUTES/ADMIN_ROUTES into one tagged list#984

Open
tcoratger wants to merge 2 commits into
leanEthereum:mainfrom
tcoratger:audit/arch-18-unify-route-lists
Open

refactor(api): unify ROUTES/ADMIN_ROUTES into one tagged list#984
tcoratger wants to merge 2 commits into
leanEthereum:mainfrom
tcoratger:audit/arch-18-unify-route-lists

Conversation

@tcoratger

Copy link
Copy Markdown
Collaborator

Summary

The API route definitions kept two parallel containers: a ROUTES dict for
read-only GET endpoints and an ADMIN_ROUTES list of (method, path, handler)
triples for the admin verbs. A reader had to cross-reference both to see the full
surface, and registration walked them with two different comprehensions.

This unifies them into a single Route table. Each entry is a small NamedTuple
carrying the HTTP method, path, handler, and an is_admin flag that tags its
access tier. Registration now iterates one list with a single web.route call.

The exact set of registered routes and their admin gating is preserved.

Changes

  • src/lean_spec/node/api/routes.py: replace ROUTES dict and ADMIN_ROUTES
    list with one Route NamedTuple and a single ROUTES list tagged by tier.
  • src/lean_spec/node/api/server.py: register from the one table; drop the
    second comprehension and the ADMIN_ROUTES import.

Testing

  • uv run pytest tests/node/api/test_server.py -q — 19 passed
  • just check — clean

🤖 Generated with Claude Code

tcoratger and others added 2 commits June 12, 2026 16:18
Replace the two parallel route containers with a single Route table.
Each entry carries its HTTP method, path, handler, and an is_admin tier flag.
Registration now iterates one list instead of two, with no behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts:
#	src/lean_spec/node/api/server.py
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.

1 participant