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.
58 lines
2.2 KiB
Markdown
58 lines
2.2 KiB
Markdown
---
|
|
# quotesdb-4gqi
|
|
title: Implement GET /api/quotes — paginated list with author filter (case-insensitive) and tag filter
|
|
status: completed
|
|
type: task
|
|
priority: normal
|
|
created_at: 2026-03-10T23:32:08Z
|
|
updated_at: 2026-03-10T23:32:16Z
|
|
blocked_by:
|
|
- quotesdb-6ng5
|
|
- quotesdb-fagr
|
|
- quotesdb-qf7x
|
|
---
|
|
|
|
<context>
|
|
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` returns a paginated list of quotes. Query parameters:
|
|
- `page` (default 1): page number (1-indexed)
|
|
- `author`: case-insensitive author filter (partial match acceptable)
|
|
- `tag`: filter to quotes that have this tag
|
|
|
|
Response shape: `{"quotes": [...], "page": N, "total_pages": N, "total_count": N}`. Page size is 10.
|
|
</context>
|
|
|
|
<goal>
|
|
Implement the `GET /api/quotes` handler with pagination, optional author filter, and optional tag filter. Each quote in the response must include its tags (fetched from `quote_tags`). Return the pagination metadata in the response envelope.
|
|
</goal>
|
|
|
|
<constraints>
|
|
- Author filter should be case-insensitive (`LIKE lower(?)` or `COLLATE NOCASE`).
|
|
- Tag filter requires a JOIN with `quote_tags` — ensure the query doesn't return duplicate quotes when a quote has multiple tags.
|
|
- Out-of-range page numbers should return an empty `quotes` array, not a 404.
|
|
- Tags must be fetched for each returned quote — either via a JOIN or N+1 queries (N+1 is acceptable for now given small dataset size).
|
|
</constraints>
|
|
|
|
<skills>
|
|
Use `superpowers:test-driven-development` — write tests for: page=1 default, page=2 with 15 quotes, author filter, tag filter, combined filters.
|
|
Use `superpowers:verification-before-completion` before closing.
|
|
</skills>
|
|
|
|
<validation>
|
|
Run in order from the `quotesdb/` directory:
|
|
|
|
```sh
|
|
cargo fmt
|
|
cargo check
|
|
cargo clippy
|
|
cargo test
|
|
```
|
|
</validation>
|
|
|
|
<commit>
|
|
`feat(quotesdb): implement GET /api/quotes — paginated list with author and tag filters`
|
|
</commit>
|