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 Integration Tests

Integration tests for the quotesdb API, located in this directory.

Running

# From quotesdb/
cargo test

Integration tests run automatically as part of cargo test.

Structure

Each test file focuses on one area of the API:

File Coverage
api_spec.rs GET /api/ — OpenAPI spec shape
quotes_list.rs GET /api/quotes — pagination, filters
quotes_random.rs GET /api/quotes/random — 200 and empty DB
quotes_crud.rs PUT, POST, DELETE — create, update, delete
auth.rs Auth code validation, 403 responses
tags.rs Tag create, filter, replace on update
router_order.rs /random not matched as :id

Test harness

All tests use a shared harness (harness.rs) that:

  1. Creates a temporary SQLite database
  2. Spawns an Axum server on a random port
  3. Returns the server address for reqwest clients to hit
  4. Cleans up the database on drop

Notes

  • Tests require no external services — all run against a local SQLite database
  • Each test gets its own isolated database to avoid state contamination
  • The API server target must build natively (cargo test uses the host target)