Skip to content

Add additive API-simplification sugar layer - #23

Merged
magi8101 merged 11 commits into
mainfrom
feat/api-simplification-sugar-layer
Sep 19, 2026
Merged

magi8101 merged 11 commits into
mainfrom
feat/api-simplification-sugar-layer

Conversation

@magi8101

Copy link
Copy Markdown
Member

Summary

  • add_middleware(cls, **kwargs) now works directly — no functools.partial needed for configured middleware
  • Six enable_* convenience methods on Velocix: enable_cors, enable_csrf, enable_sessions, enable_rate_limit, enable_gzip, enable_trusted_hosts — one call each, no need to know the underlying middleware class/module
  • Top-level velocix now also exports BaseHTTPMiddleware, TrustedHostMiddleware, GZipMiddleware, CSRFMiddleware, Body, and Struct (= msgspec.Struct)
  • README and examples/openapi_example.py updated to demonstrate the new helpers; dropped the example's redundant enable_auto_docs() call since Velocix() already auto-generates /docs//redoc//openapi.json

Purely additive — every existing import, class, and method signature keeps working unchanged. Design/plan docs: docs/superpowers/specs/2026-09-19-api-simplification-sugar-layer-design.md, docs/superpowers/plans/2026-09-19-api-simplification-sugar-layer.md.

Test plan

  • 10 new tests in tests/test_app_sugar.py covering kwargs-based add_middleware (plus bare-class/partial regression coverage) and each enable_* helper
  • Full suite: 272/272 passing
  • ruff check . clean
  • mypy velocix clean

Covers add_middleware(cls, **kwargs) without functools.partial,
enable_cors/csrf/sessions/rate_limit/gzip/trusted_hosts convenience
methods, a top-level export audit, and a README/example refresh.
Purely additive -- no existing API changes.
Four TDD tasks: add_middleware kwargs support, six enable_* convenience
methods, top-level export audit, README/example refresh.
…e, CSRFMiddleware, Body, Struct from top-level velocix
Copilot AI lite review requested due to automatic review settings September 19, 2026 16:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@magi8101
magi8101 merged commit 7eb22d9 into main Sep 19, 2026
2 checks 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.

2 participants