Skip to content

fix(api): implement /api/v1/markets/{market_id}/cancel route and integrate cancel page - #1817

Merged
hman38705 merged 1 commit into
solutions-plug:mainfrom
shemaiahdelia03-cmd:fix/1754-cancel-market-route
Oct 20, 2026
Merged

hman38705 merged 1 commit into
solutions-plug:mainfrom
shemaiahdelia03-cmd:fix/1754-cancel-market-route

Conversation

@shemaiahdelia03-cmd

Copy link
Copy Markdown
Contributor

Closes #1754

Summary

Implements the missing backend route POST /api/v1/markets/{market_id}/cancel and integrates it with the typed frontend admin client and cancellation page.

Changes

  • Backend (services/api):
    • Registered POST /api/v1/markets/:market_id/cancel in services/api/src/main.rs under admin_routes.
    • Implemented cancel_market handler in services/api/src/handlers.rs with utoipa OpenAPI annotations.
    • Added cancel_market method in services/api/src/db.rs to transition active markets to cancelled status.
    • Added InvalidationTag::MarketCancelled in services/api/src/cache/mod.rs to invalidate market and statistics caches upon cancellation.
    • Added audit log action mapping for cancel_market in services/api/src/audit_middleware.rs.
    • Registered cancelMarket path and operation in services/api/openapi.yaml, openapi_spec.rs, and services/api/tests/openapi_contract_test.rs.
    • Added regression unit tests in services/api/src/cancel_market_tests.rs.
  • Frontend (frontend):
    • Updated frontend/src/lib/api/schema.d.ts with cancelMarket path and operation.
    • Added cancelMarket in frontend/src/lib/api/admin-client.ts.
    • Refactored CancelMarketPage (frontend/src/app/markets/[marketId]/cancel/page.tsx) to use typed api.cancelMarket(marketId) with contract error handling.
    • Added contract tests in frontend/src/lib/api/__tests__/ for cancelMarket.
  • Documentation:
    • Updated docs/API_SPEC.md with cancelMarket under Admin Routes.

…and client integration

- Added POST /api/v1/markets/:market_id/cancel route and cancel_market handler in services/api
- Added cancel_market method in Database and InvalidationTag::MarketCancelled in RedisCache
- Registered cancelMarket endpoint in services/api/openapi.yaml and openapi_spec.rs
- Updated admin_routes, audit_middleware, and openapi_contract_test with cancelMarket
- Added cancelMarket method in frontend admin-client.ts and generated schema in schema.d.ts
- Connected CancelMarketPage to typed admin-client cancelMarket method with contract error handling
- Added unit and contract tests in services/api and frontend/src/lib/api/__tests__
- Updated API_SPEC.md documentation

Closes solutions-plug#1754
@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@shemaiahdelia03-cmd Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@hman38705
hman38705 merged commit c8b75dd into solutions-plug:main Oct 20, 2026
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.

Cancel-market page POSTs to /api/v1/markets/{id}/cancel which has no backend route

2 participants