+++ title = "Implement GET /api/quotes/random — random row query (must be registered before /:id route)" priority = 5 status = "todo" ticket_type = "task" dependencies = ["a5049d", "d792e2", "175382"] +++ The `quotesdb` API is built with Axum + Tokio, targeting Cloudflare Workers via `workers-rs`. It serves JSON at `/api/*` endpoints and persists data to Cloudflare D1 (production) or a local SQLite file via Turso (development). Source lives in `src/bin/api/`. Shared types and utilities are in `src/lib.rs` — code placed there must compile for both the host target and `wasm32-unknown-unknown`. `GET /api/quotes/random` returns a single random quote from the database. This endpoint **must be registered before** `GET /api/quotes/:id` in the Axum router, or it will never be reached (Axum matches in registration order and ":id" would match the literal string "random"). Implement the `GET /api/quotes/random` handler that selects a random row from the `quotes` table and returns it with its tags. Return 404 if the database is empty. - **Router ordering is critical** — document the ordering requirement in a comment in `main.rs`. - Use `ORDER BY RANDOM() LIMIT 1` for SQLite random selection. - Include the quote's tags in the response. - Return `404 Not Found` with `{"error": "no quotes available"}` if the table is empty. Use `superpowers:test-driven-development` — write tests for: random quote returned (non-empty DB), 404 when DB is empty. Use `superpowers:verification-before-completion` before closing. Run in order from the `quotesdb/` directory: ```sh cargo fmt cargo check cargo clippy cargo test ``` `feat(quotesdb): implement GET /api/quotes/random`