---
name: supabase-ssl-api
overview: Introduce a consistent response builder, refactor registry/query handlers to use it, and add the new Supabase SSL enforcement POST endpoint under `/api/v2/supabase/ssl_enforcement` so the API can toggle SSL with structured payloads.
todos:
  - id: response-builder
    content: Create the shared response builder module and wire it into the public API.
    status: completed
  - id: refactor-registry-query
    content: Refactor the registry and SQL query handlers to use the builder for success/error responses.
    status: completed
  - id: supabase-ssl-endpoint
    content: Add the /api/v2/supabase/ssl_enforcement handler (with Reqwest logic) and document it.
    status: completed
  - id: todo-1769516881776-kgs5jmdz8
    content: "Update the openapi.yaml api spec with the new route "
    status: pending
  - id: todo-1769516905834-i6kqn1ogu
    content: Fully update the postman collection in /postman, with every api route that is in the entire api
    status: pending
isProject: false
---

# Plan

- Add a shared response builder (e.g. `src/api/response.rs`) that centralizes
the JSON envelope format (status/message/data/error) and returns
`HttpResponse` so every handler can emit the same schema with the appropriate
HTTP status code instead of ad hoc `json!` constructions. This module should
export helpers like `api_success`, `api_error`, `bad_request`, etc., plus any
helpers for caching wrappers (used in the registry).
- Update the registry handlers
(`[src/api/registry/mod.rs](src/api/registry/mod.rs)`) and the SQL query
handler (`[src/api/query/sql/mod.rs](src/api/query/sql/mod.rs)`) to use the
new builder functions instead of directly constructing
`HttpResponse::Ok().json(...)` and inconsistent error bodies, ensuring both
the cached branches and the driver-specific paths follow the envelope.
- Implement the new Supabase SSL endpoint in a dedicated module (e.g.
`[src/api/supabase.rs](src/api/supabase.rs)`): parse a POST JSON body that
accepts `access_token`, `project_ref`, and a boolean `enabled` field (falling
back to the same env vars as the CLI), call the Supabase management API via
`AppState::client`, and return results through the shared response builder.
Register this route in `[src/main.rs](src/main.rs)` under
`/api/v2/supabase/ssl_enforcement` and export it from
`[src/api/mod.rs](src/api/mod.rs)`.
- Update documentation (either `README.md` or the new module docstrings) to
mention the new endpoint and the expected request shape, plus how it mirrors
the CLI script (`scripts/ssl_enforcement.py`).

Todos:

- response-builder: Create the shared response builder module and wire it into
the public API.
- refactor-registry-query: Refactor `registry` and `query/sql` to use the
builder for success/error responses.
- supabase-ssl-endpoint: Add the `/api/v2/supabase/ssl_enforcement` handler that
toggles SSL enforcement and document the request.

