Skip to content

Make API router prefix configurable#14

Merged
dceoy merged 8 commits intomainfrom
codex/remove-api-v1-prefix
Mar 15, 2026
Merged

Make API router prefix configurable#14
dceoy merged 8 commits intomainfrom
codex/remove-api-v1-prefix

Conversation

@dceoy
Copy link
Copy Markdown
Owner

@dceoy dceoy commented Mar 15, 2026

Summary

  • remove the hardcoded /api/v1 default so the API serves root-level routes unless a prefix is configured
  • centralize router mounting behind API_ROUTER_PREFIX and allow deployments to set the prefix via environment variable
  • update tests, documentation, specs, OpenAPI artifacts, and MT5 agent skills to match the current routes and API behavior

Testing

  • .agents/skills/local-qa/scripts/qa.sh

Notes

  • the default router prefix is "", so existing routes in this branch remain unprefixed
  • API_ROUTER_PREFIX normalizes values like api/v1, /api/v1, and /api/v1/ to the same mounted prefix

@dceoy dceoy added documentation Improvements or additions to documentation enhancement New feature or request codex labels Mar 15, 2026
@dceoy dceoy force-pushed the codex/remove-api-v1-prefix branch from 955c49a to 4801403 Compare March 15, 2026 16:03
@dceoy dceoy changed the title Remove /api/v1 route prefix Make API router prefix configurable Mar 15, 2026
@dceoy dceoy self-assigned this Mar 15, 2026
@dceoy dceoy marked this pull request as ready for review March 15, 2026 17:06
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Clean, well-structured PR. The separation into constants.py and config.py is sound, naming follows project conventions, and the parametrized tests for normalize_api_router_prefix are thorough. A few items worth addressing below.

What works well

  • normalize_api_router_prefix is well-designed with clean logic and good edge-case coverage in tests
  • constants.py eliminates scattered magic strings — genuine maintainability win
  • Consistent Google-style docstrings and type annotations throughout
  • Auth dependencies are unaffected by the routing changes — no bypass risk
  • Config is resolved once at startup, not per-request — correct pattern

Suggestions (see inline comments)

  1. Add input validation to normalize_api_router_prefix — values like ../../admin or api?x=1 pass through unchallenged and could confuse reverse proxies
  2. Add test for get_configured_mt5_api_key empty-string coercionMT5_API_KEY="" silently disables auth via the or None pattern, which is security-relevant and should be explicitly tested
  3. Consider adversarial inputs in prefix testsapi//v1, api?v=1, path traversal patterns
  4. importlib.reload test fragility — consider an app factory pattern to avoid module-level side effects in tests

Comment thread mt5api/config.py
Comment thread mt5api/config.py
Comment thread tests/test_config.py
@dceoy dceoy merged commit cd42cee into main Mar 15, 2026
5 checks passed
@dceoy dceoy deleted the codex/remove-api-v1-prefix branch March 15, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant