You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Elijah Voigt a5b7c8d856 feat(quotesdb): implement API DB layer and all HTTP handlers
DB layer (src/bin/api/db/):
- native.rs: NativeRepository (tokio-rusqlite) implementing all CRUD ops,
  dynamic WHERE for filters, two-phase auth check for update, 13 unit tests
- d1.rs: D1Repository wasm32 stub (all methods return Internal error)
- connection.rs: open() helper — WAL + foreign_keys pragmas
- mod.rs: cfg-gate async_trait (Send on native, ?Send on wasm32)

Handlers (src/bin/api/handlers/mod.rs):
- All 7 routes: GET /api/, random, {id}, list, PUT create, POST update, DELETE
- Router order: random BEFORE {id} (prevents "random" matching as id)
- Auth: X-Auth-Code header validation → 403 on mismatch
- 13 handler unit tests with MockRepo

main.rs: opens DB, runs migrations, wraps in Arc<dyn Repo + Send + Sync>,
  binds on $PORT (default 3000)

Cargo.toml: tower dev-dep for ServiceExt::oneshot in tests

All 32 tests pass (26 api + 6 lib)

Tickets closed: 00aff0 a5049d 6e829e 28e7d9 886bfd 2ce22e 5dbb7d 05f8ae
                d792e2 5d9f5a b20b5a 175382 03bb91

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3 months ago
..
README.md feat(quotesdb): implement API DB layer and all HTTP handlers 3 months ago

README.md

quotesdb UI

Yew/Wasm single-page application for browsing and submitting quotes. Compiled by Trunk and hosted on Cloudflare Pages.

Running locally

# Terminal 1 — start the API server
cargo run

# Terminal 2 — start the Trunk dev server
trunk serve

Open http://localhost:8080. The Trunk proxy forwards /api/* to localhost:3000.

Building for production

trunk build --release

Output is in dist/. Deploy with:

wrangler pages deploy dist/ --project-name quotesdb-ui

Pages

Route Description
/ Home — random quote + Browse link
/browse Paginated list with author/tag filters
/quotes/:id Single quote — view, edit, delete
/author/:name All quotes by an author
/submit Create a new quote

Architecture

  • Framework: Yew 0.22 with yew-router 0.19
  • API calls: gloo::net::http::Request (not reqwest — wasm32 incompatible)
  • Auth storage: sessionStorage via web_sys — key: auth_code_{quote_id}
  • CSS: Plain CSS, BEM naming (no Tailwind)
  • SPA routing: _redirects file (/* /index.html 200) copied to dist/ by Trunk