refactor(api): unify ROUTES/ADMIN_ROUTES into one tagged list#984
Open
tcoratger wants to merge 2 commits into
Open
refactor(api): unify ROUTES/ADMIN_ROUTES into one tagged list#984tcoratger wants to merge 2 commits into
tcoratger wants to merge 2 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The API route definitions kept two parallel containers: a
ROUTESdict forread-only GET endpoints and an
ADMIN_ROUTESlist 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
Routetable. Each entry is a smallNamedTuplecarrying the HTTP method, path, handler, and an
is_adminflag that tags itsaccess tier. Registration now iterates one list with a single
web.routecall.The exact set of registered routes and their admin gating is preserved.
Changes
src/lean_spec/node/api/routes.py: replaceROUTESdict andADMIN_ROUTESlist with one
RouteNamedTuple and a singleROUTESlist tagged by tier.src/lean_spec/node/api/server.py: register from the one table; drop thesecond comprehension and the
ADMIN_ROUTESimport.Testing
uv run pytest tests/node/api/test_server.py -q— 19 passedjust check— clean🤖 Generated with Claude Code