Skip to content

Conversation

oliveror
Copy link
Member

Summary

  • Index recipe, ingredient and tag searches, validate browse filters, and restore cookbook search and navigation when returning from a recipe.
  • Preserve recipe drafts across reloads, detect conflicting edits, and focus invalid form fields.
  • Improve keyboard navigation, focus management, and contrast. Reduce the initial Explore bundle and cache recipe image variants.
  • Limit GraphQL request sizes and recipe creation, split browser tests into independent scenarios, and update setup and demo data documentation.

olestan and others added 30 commits October 29, 2026 15:59
* style(recipes): improve recipe form layout and image upload UI

* style(recipes): improve drag handle styling and alignment

* style(auth): refine login and registration form spacing

* test: update tests
* chore(recipes): add seeded recipes with local images

* fix(seed): isolate test image uploads from application storage

* docs: update documentation
* Improve recipe sorting, query caching and accessibility coverage

* docs: summarize delivery 3 review improvements and HTTPS clarification

---------

Co-authored-by: hasan.fawzi <hasan.fawzi@hoglund.no>
The unknown-recipe page rendered only an EmptyState h3, so it had no
top-level heading (axe: page-has-heading-one). EmptyState now takes an
optional headingLevel (default 3, unchanged visuals) and the not-found
state uses level 1
Native <select> arrow keys change the value on Linux and Windows but open
the option popup on macOS, so two keyboard tests failed locally on Macs.
Choose options with type-ahead instead, which works on every platform and
keeps the tests keyboard-only.
* docs: add credits.md and update existing documentation
* chore(api): serve GraphiQL only when API_GRAPHIQL=true. The deployed API served an interactive GraphiQL editor to anyone. Make it opt-in.
* fix(a11y): raise brand colour contrast to WCAG AA

White text on the brand orange (#e86a1c) was 3.23:1 and orange text on the
light surfaces was below 4.5:1, failing axe color-contrast on most pages.
Shift the brand ramp one step darker (primary #a8470b, hover #9a3f08,
active #8f3a06) and use secondary text for the desktop servings hint.

Add an axe-core Playwright suite that checks WCAG 2.x A/AA rules on public
and signed-in pages at desktop and mobile widths, so contrast regressions
fail CI.

Closes #67

* test(a11y): scan after recipe data has rendered; realistic cookbook

Review on #86 (non-blocking): Explore and Cookbook now wait for the
recipe card link before running axe, so the scan covers the loaded
results rather than the loading state, and the Cookbook mock returns a
recipe the user has saved.

Refs #67
* fix(recipe): open the recipe when its card image is clicked

Only the title link opened a recipe; clicking the image did nothing. Wrap
the image in a link to the same page that is hidden from assistive
technology and the tab order, so keyboard and screen-reader users still
get a single link per card. Both links keep the browse state for Back.

Closes #82

* test(recipe): cover card image clicks instead of adding a second link

Review on #90 was right: the title link's ::after overlay already covers
the whole card, so clicking the image already opened the recipe (checked
in a real browser). The extra aria-hidden image link was redundant and
hid the image alt text from screen readers. Restore RecipeCard as before
and add a browser test that clicks the image centre, since jsdom cannot
hit-test the CSS overlay.

Closes #82
* fix(a11y): move focus to the results after a page change

Changing page scrolled to the top but left keyboard focus on the
pagination button at the bottom, so keyboard and screen-reader users lost
their place. Explore and Cookbook now focus the results heading, which
stays mounted while the next page loads.

Closes #81

* fix(a11y): focus the visible result count after a page change

Review on #91: focusing the sr-only heading left sighted keyboard users
without a visible focus ring, and the result count (role=status) was
unmounted while the next page loaded, so the update might not be
announced. Explore and Cookbook now keep the count mounted (showing
"Loading recipes…" while loading) and move focus to it; it is visible
text, so the global :focus-visible ring shows.

Refs #81
* chore(web): remove dead code and mount review pages in dev only

- Remove the unused search/setSearch store fields and the unused
  data/users.ts mock user.
- The UI showcase, RecipeCard showcase, style guide and style stress tests
  were no longer reachable from App. Mount them at /dev/* behind
  import.meta.env.DEV, so they are usable in npm run dev and excluded from
  the production bundle, and document the routes in the UI README.

Closes #79

* fix(web): one main landmark per dev page and a dev 404 fallback

Review on #92: the showcases and style tests each rendered their own
<main>, so pages had several main landmarks; they now use <section>, and
DevPages wraps each page in a single <main>. Unknown /dev/* routes show
NotFoundPage instead of a blank page.

Refs #79
* chore(data): write real seed descriptions and seed demo ratings

- Replace the generated "A homemade … recipe" filler with a hand-written
  description for each of the 51 demo recipes, checked against their
  ingredients and steps. Seeding now fails if a recipe has none.
- Add four demo taster accounts that give deterministic 3-5 star ratings
  to about 80 % of the public demo recipes, so Highest rated sorting has
  data. Private recipes are not rated. Re-running the seed adds nothing.

Not done here (needs the team and VM access): deleting the "4" test
recipe from production and re-running the seed on the VM.

Refs #75

* fix(data): make the demo seed robust to taken taster emails

Review on #94:
- If another account already uses a taster address, the seed now skips
  that taster's ratings with a warning instead of failing a foreign key
  and rolling back the whole seed.
- Registration refuses the reserved demo addresses (demo@ and
  demo-taster-N@example.invalid), answered like an existing email.
- The seed test checks descriptions stored in the database, after first
  setting them to stale text, so it catches failed updates; it also
  covers a pre-existing account on a taster address.

Refs #75
…ts (#96)

* fix(recipe): open the recipe when its card image is clicked

Only the title link opened a recipe; clicking the image did nothing. Wrap
the image in a link to the same page that is hidden from assistive
technology and the tab order, so keyboard and screen-reader users still
get a single link per card. Both links keep the browse state for Back.

Closes #82

* feat(perf): cache images and assets, serve image thumbnails

- Images: replace Cache-Control no-store with no-cache plus a strong ETag
  (public/private by recipe visibility). The access check still runs on
  every request, so privacy changes apply immediately, but unchanged
  images are answered with an empty 304 instead of being re-downloaded.
- Thumbnails: the API generates 480/800 px WebP variants (?w=) with sharp
  on first request and caches them under UPLOAD_DIR/variants; cleanup
  removes them with the original. Recipe cards use srcset/sizes.
  A seed image goes from 133.6 KB to 18.2 KB at 480 px.
- Apache: immutable one-year caching for hashed /assets, no-cache for
  index.html (deploy/apache.conf, needs mod_headers on the VM).
- Fallback image resized to 800 px: 173.4 KB -> 51.2 KB.
- GraphQL responses keep no-store.

Closes #70

* feat(images): normalise uploads on the server and cover all variants

Following team review of #70:
- Every upload is processed with sharp on the server, whatever the client
  sent: EXIF auto-rotation, at most 1600 px on the longest side, WebP
  quality 80, metadata (e.g. GPS) dropped. Quotas use the stored size.
  Existing files and URLs are unchanged.
- Card variants (480/800 px) are built at upload time; older images still
  get them lazily. The recipe detail image now uses srcset/sizes too.
- The global storage limit counts variant files. Variants already go
  through the same authorization (incl. privacy changes) and cleanup.

Refs #70

* test(recipe): cover card image clicks instead of adding a second link

Review on #90 was right: the title link's ::after overlay already covers
the whole card, so clicking the image already opened the recipe (checked
in a real browser). The extra aria-hidden image link was redundant and
hid the image alt text from screen readers. Restore RecipeCard as before
and add a browser test that clicks the image centre, since jsdom cannot
hit-test the CSS overlay.

Closes #82

* fix(images): refresh replaced images, rotate variants, remove orphans

Review on #96:
- ETags include the original's size and mtime, and cached variants are
  rebuilt when the original is newer, so re-seeded images (same
  filenames) are never shown stale.
- Variants apply EXIF auto-rotation, so older JPEG uploads stored before
  server-side normalisation are not shown sideways.
- Cleanup removes variants (and interrupted .tmp writes) whose original
  no longer exists, so they stop counting against the storage limit.

Refs #70
* feat(perf): cut initial JavaScript for Explore by about a third

- Generate client operations as typed query strings (codegen
  documentMode: 'string') and send them as-is, so the browser no longer
  bundles graphql-js for print(); remove graphql from apps/web.
- Lazy-load Login, Register, Cookbook, Recipe detail and Add/Edit recipe;
  AppShell shows a loading state while a page chunk loads.
- Validate recipe ids with Zod's UUID pattern instead of importing Zod,
  which kept the whole library in the landing bundle.

Initial JS for Explore: 131.8 KB -> 90.1 KB gzipped.

Closes #83

* docs(perf): record bundle sizes before and after code splitting

Refs #83

* fix(perf): fix cascade layer order for code-split CSS

With lazy routes, Vite links page-chunk stylesheets before the main
stylesheet. Cascade layer priority follows the order layers are first
named, so the components layer landed below the reset and primary
buttons lost their white text. Declare the layer order inline at the top
of index.html, and add a smoke test that checks a code-split page.

Refs #83

* test(auth): wait for the lazy-loaded Register page

CI failed in RequireAuth.test (register=true): with code splitting the
Register page loads asynchronously, and the test looked up the Name field
right after clicking the link. On the slower CI runner the chunk was not
loaded yet. Wait for the Register heading first, as the test already does
for Log in.

Refs #83

* docs(api): use string GraphQL documents in the client example

The generated documents are now TypedDocumentString, so the example sends
CreateRecipeDocument.toString() instead of print() and no longer imports
graphql.
)

* fix(a11y): make ingredient and step reordering keyboard accessible

Rows could only be reordered by dragging (fails WCAG 2.2 SC 2.5.7) and
used array indexes as React keys, so DOM state could stay behind when
rows moved. Each row now has a stable key, and Move up / Move down
buttons that keep focus on the moved row (or its other button at the
first/last place) and announce the new position in a live region.
Drag-and-drop still works. On phones the row buttons move to their own
line under the fields. The test named 'button-based reordering' (which
actually dragged) is renamed and a keyboard test is added.

Closes #104

* test(recipe): make the keyboard reordering test fast enough for CI

The test timed out on the CI runner (5056 ms of 5000 ms) because it typed
every field character by character. It now fills fields with
fireEvent.change and keeps real keyboard interaction for the moves it
tests; it runs in about 0.4 s locally.

Refs #104
)

The API and the recipe form allowed 1-1000 servings, but the detail page
stopped at 20 and only had -/+ buttons. MIN_SERVINGS/MAX_SERVINGS now
live in @t31/validation/recipe and are used by the API, the form and the
detail page. A shared ServingsStepper keeps the -/+ buttons and makes the
number a field: valid whole numbers apply while typing; out-of-range or
empty input is clamped or restored when leaving the field.

Closes #101
* fix(recipe): use English ingredient units with legacy mapping

The editor offered Norwegian units (ss, ts, stk) in an otherwise English
UI. A shared ingredientUnits module now lists English units (g, kg, ml,
dL, L, tsp, tbsp, cup, pcs), and maps legacy ss/ts/stk to tbsp/tsp/pcs
in the editor and the detail view, so stored recipes keep working without
a data migration (saving stores English). Custom stored units such as
"cloves" stay selectable.

Closes #99

* fix(recipe): only map defined legacy units, not inherited properties

normalizeUnit() looked units up with a plain index, so free-text units such
as "__proto__" or "constructor" resolved to inherited object properties
and returned a non-string. Lookups now use Object.hasOwn().
* feat(a11y): add a skip-to-content link

Keyboard users had to tab through the whole header on every page. A
"Skip to main content" link is now the first tab stop: hidden until
focused, then shown top left in white on the dark text colour. It moves
focus to <main id="main-content" tabIndex={-1}> without adding a hash
to the URL. Browser test covers focus order, visibility, colours and the
focus move.

Closes #102

* fix(a11y): keep the skip-link target clear of the sticky header

Focusing <main> on a scrolled-down page scrolled it behind the sticky
header, hiding its first control (e.g. Back on recipe detail). main now has
scroll-margin-top of the header height (new --site-header-height token,
also used by the header). E2E: on a long, scrolled recipe page, skip link
then Tab focuses Back fully in view and below the header.
* feat(a11y): set page titles and move focus to main on navigation

Every page now sets a document title ("My Cookbook – Recipe Platform",
the recipe's name on detail pages). When the pathname changes, AppShell
scrolls to the top and moves focus to main, as a full page load would, so
screen readers start on the new page. Not on first load, not for query
string changes (search, filters, paging) and not while a dialog is open.

Closes #103

* fix(a11y): keep Back/Forward scroll position; title auth and edit error states

- AppShell no longer scrolls to the top on Back/Forward (POP), so the
  browser's restored position is kept; focus still moves to main.
- RequireAuth titles its own states ("Restoring session", "Session could
  not be restored"), so a protected page that cannot render no longer
  keeps the previous page's title.
- The edit page titles each state: "Recipe could not be loaded",
  "Recipe unavailable", "Cannot edit recipe"; "Edit <title>" only when
  editing. A PageTitle component sets titles from such branches, since a
  parent's unconditional usePageTitle would override the child page's.
* feat(recipe): persist recipe drafts across navigation and reload

"Save draft" only showed a message; the draft was lost on navigation or
reload. Drafts are now stored in localStorage per user and recipe
(lib/recipeDrafts.ts). Opening the form offers to restore or discard a
saved draft, warns when the recipe changed after the draft was saved,
leaves out an uploaded image that no longer loads, and clears the draft
after a successful save. Signing out removes the user's drafts.

Closes #105

* test(recipe): fill draft test fields without per-key typing

Keeps the draft tests well under the CI runner's 5 s test limit, like the
reordering test.

Refs #105

* fix(recipe): make draft restore, status and cleanup safe against races

- Restoring a draft image blocks Save draft and submit until the image
  check finishes; choosing or removing an image cancels the check, so a
  late answer can no longer replace the user's newer choice.
- Drafts are validated field by field when loaded; malformed ones are
  dropped instead of breaking restore or save.
- "Draft saved" is only shown while the form still matches what was saved,
  so changing tags, the image, or adding/removing/moving rows hides it.
- Sign-out reads the user id before awaiting the request.
- Discard and successful save only remove a draft version this tab offered
  or saved; a newer draft from another tab is kept (and the user is told).
* fix(a11y): move focus to the recipe when using Jump to recipe

The button only scrolled: keyboard focus stayed on it, and smooth
scrolling ignored prefers-reduced-motion. It now focuses the Ingredients
heading after scrolling (so screen readers announce the destination and
Tab continues there) and scrolls instantly when reduced motion is
preferred.

Closes #106

* fix(a11y): jump to the servings control so Tab stays in the recipe

Focusing the Ingredients heading announced the right place, but the
ingredient and step lists have nothing tabbable, so the next Tab left the
recipe. Jump to recipe now lands on the visible "Adjust Servings" heading,
directly above the ingredients; Tab continues to the servings buttons that
scale them. The control exists once per layout and CSS hides the other, so
the rendered copy is picked (falling back to the Ingredients heading).
scroll-margin-top keeps it clear of the sticky header.

Playwright, desktop and mobile: Enter on Jump focuses the heading in view
below the header, then Tab reaches Decrease and Increase servings.
…117)

* feat(recipe): refresh stale data when returning to a long-open page

Recipe reads were cached for 30 s, but a page left open never refreshed.
useRecipeQuery now refetches when the window regains focus or the tab
becomes visible, if the shown data is older than RECIPE_FRESHNESS_MS
(30 s). It reuses the background-refresh path, so the grid stays visible,
and the recipe editor opts out (refreshWhenStale: false) so typed input
is never replaced.

Closes #107

* fix(recipe): only mark data fresh after a successful refresh

fetchedAt was set when a background refresh started, so a failed refresh
left old data marked fresh for another 30 seconds. It is now only set when
a request succeeds, and a separate in-flight flag stops focus and
visibilitychange from starting the same refresh twice. Test: failed refresh,
then focus again, retries immediately.
…os (#118)

* test(e2e): split the integrated browser test into independent scenarios

The real-API browser test was one 90-second journey, so an early failure
hid everything after it. It is now six independent scenarios (image
upload and removal, editing, rating, saving to the cookbook, privacy and
deletion) plus one short end-to-end journey through the real
registration and publishing UI. Scenario users are created through the
auth service with a real session cookie, because UI registration is rate
limited to 5 per minute per IP, and recipes through the repository.

Closes #108

* test(e2e): restore image, rating-then-save and search regression checks

- The edit scenario now edits a recipe that has an uploaded image and
  checks the same image is still shown, loaded, after reload.
- The rating scenario saves to My Cookbook straight after changing the
  rating, and unsaves/saves straight after removing it; after reload the
  recipe is saved and unrated.
- The journey first searches an unrelated term and waits for the empty
  result (so a loading state cannot pass the check), then finds the recipe
  by title. Verified that ignoring the search term on the server, or
  dropping the image on save, makes the scenarios fail.

* test(e2e): use a realistically sized image in the edit scenario

The recipe page now serves images with srcset width descriptors (#96), and
the browser scales naturalWidth by the chosen density, so the 1x1 test PNG
reported 0 although it loaded. The scenario now uploads a 600x400 PNG, and
calls upload() without the extension argument #96 removed.

* test(e2e): check another user saves the edited recipe; poll image load

Restores the original journey's check that another user can save an
edited recipe and sees its new title in My Cookbook, in the edit
scenario. The upload scenario now polls naturalWidth, as the image can
be visible before it has finished loading.

Refs #108
… indexed sorting (#98)

* feat(search): index-backed word search and rating sort, tested at 100k

- Search: full-text search on a generated tsvector of title and
  description with a GIN index (config 'simple', no extension needed).
  Every word must match as a word prefix, so "chicken rice" finds
  "Rice with chicken". The query is built from letters and digits only,
  so user input cannot break the tsquery syntax. Behaviour change: words
  no longer match mid-word ("cake" does not find "pancakes").
- Highest rated: rating_avg/rating_count cached on recipes and kept in
  step by a trigger on ratings (covers API, seed and manual SQL); the
  touch trigger now ignores these columns so rating does not change a
  recipe's updated time. Summaries read the cached values.
- Partial indexes for category, total time and rating whose order matches
  each ORDER BY; the row query is skipped when the count is 0.
- npm run db:seed:large -- <n> | --remove loads or removes a generated
  catalogue (never run by CI or deploy).

Measured locally on 100 000 recipes (EXPLAIN ANALYZE, median of 3):
highest rated 439 -> 0.1 ms, quickest 42 -> 0.1 ms, search count
94 -> 10 ms; whole GraphQL list requests 2-29 ms. Numbers and method in
docs/performance-and-images.md.

Closes #69
Closes #80

* feat(search): search ingredient names and tags as well

Following team review: the search document now covers title,
description, ingredient names and tags. search_vector is a plain column
kept current by a row trigger on recipes and statement-level triggers on
recipe_ingredients/recipe_tags, so one search still hits one row per
recipe (no duplicates, exact counts, same visibility rules).

seed-large now runs VACUUM ANALYZE after loading (the triggers leave
dead rows that made counts several times slower). Docs updated with new
measurements and a warning to use a separate test database, never
production.

Refs #69, #80

* fix(search): serialize cached rating and search updates, use every search word

- rate() takes FOR NO KEY UPDATE instead of FOR SHARE: the ratings trigger
  updates the same recipe row, so two shared locks deadlocked.
  removeRating() takes the same lock first, in a transaction.
- The rating and search-vector triggers lock the recipe row(s) (in id order)
  before recomputing, so a concurrent write is counted instead of being
  overwritten from a stale snapshot.
- Moving a rating, ingredient or tag to another recipe refreshes both
  recipes (rating trigger also fires on recipe_id; update triggers use both
  transition tables).
- toSearchQuery() no longer drops words after the eighth; repeated words are
  searched once, and the 200-character input limit bounds the query.
- test:api: concurrent rate/remove through the API, interleaved raw-SQL
  writes on ratings, ingredients and tags, moved rows, and a 9-word search.

* fix(search): retry API transactions that lose a deadlock to direct SQL

The API locks a recipe before its ratings, ingredients or tags; a write
outside the API (seed, manual SQL) locks the child row first and the
recipe in its trigger, so the two can deadlock. Lock order cannot be
forced on such writers, so transaction() now rolls back and retries a
transaction that fails with 40P01 (deadlock) or 40001 (serialization),
up to three attempts with a short jittered pause.

test:api: a manual session locks a rating, the API rate() then waits for
it while holding the recipe, and the manual update's trigger waits for
the recipe. Before this change the API returned "deadlock detected"; now
it retries, succeeds, and the cached rating counts both writes.

Refs #69
…id row (#123)

* fix(recipe): check the API's size limits in the form; focus any invalid row

- MAX_INGREDIENTS, MAX_INSTRUCTIONS, MAX_TAGS and MAX_TAG_LENGTH live in
  @t31/validation/recipe and are used by the API schema and the form.
- Tags are parsed with the shared parseTags() (trimmed, lower-case, no
  repeats), so the form counts and sends what the API stores. More than
  30 tags or a tag over 50 characters is a field error on Tags.
- Add ingredient / Add step are disabled at the limit with a visible
  explanation; a recipe or restored draft with too many rows gets a
  message above the list.
- After a failed submit, focus moves to the first invalid control in
  page order (any row), instead of a fixed list that only knew row 1.

Closes #120

* fix(recipe): keep row-limit errors until the list is within the limit

Removing one ingredient or step cleared the "at most 100" message even when
the list still had too many rows, so the form looked valid until the next
submit. The message now stays and shows the remaining number to remove,
and goes away only when the list fits.

Restoring a draft with more rows than the API accepts also cleared every
error, so the problem only appeared on submit. Restoring now shows the
row-count messages straight away. Both paths share one helper, built on
MAX_INGREDIENTS and MAX_INSTRUCTIONS from @t31/validation/recipe, which
validation on submit uses as well.

Tests: the message recounts after each removal and clears at the limit
(ingredients and steps); an over-limit draft shows both messages when
restored.
#124)

* fix(recipe): protect recipe edits from conflicts, leaving and sign-out

- updateRecipe takes an optional expectedUpdatedAt. The editor sends the
  version it loaded; if the recipe changed since (another tab or device)
  the API refuses with CONFLICT under the row lock, and the form keeps the
  user's changes with an explanation of how to keep them.
- Unsaved changes (form differs from how it opened and from the draft in
  this browser) trigger the browser's prompt on reload/close and, through
  a data router (createBrowserRouter) and useBlocker, a Leave/Stay dialog
  for in-app navigation. A successful save navigates away unasked.
- Sign-out asks first when it would delete saved drafts or close the
  editor with unsaved changes, and says which.
- Save draft asks before replacing a draft that was offered but not
  restored or discarded, or that another tab saved meanwhile.
- After logging in from /recipes/<id>/edit the user returns to that
  editor (strict UUID pattern, no other paths).

Closes #121

* test(auth): allow for the lazy Log in page's first import on CI

The redirect test waited 1 s (the default) for the lazy-loaded Log in
page. As the file's first test it pays the cold import, which took 1.6 s
on the CI runner once the header imported the confirmation dialog.

Refs #121

* fix(recipe): keep protecting editor changes when sign-out fails

Confirming sign-out clears the shared unsaved flag so the editor does not
ask again while it closes. If sign-out then failed, the flag stayed off
and the editor's leave and reload prompts were disabled for the rest of
the session. The previous value is now restored on failure.

Refs #121

* fix(recipe): warn about a pending image and about drafts changed elsewhere

Choosing an image opens the crop dialog and uploads it later, and until
then nothing in the form differs, so reloading or leaving discarded the
pending image without a warning. A picked image that is not uploaded yet
now counts as an unsaved change.

The editor also remembered the draft it had saved or restored and
treated the form as kept for good. If another tab replaced or deleted
that draft, leaving still passed without a warning and the changes were
lost. It now reads the draft stored in this browser whenever it changes
(storage event, saving, discarding) and compares the form against that.

* test(recipe): give the drag-reorder test time on slow CI

The test types and drags through the whole form and took about 4.95 s on the CI runner against vitest's 5 s default, timing out once. Give it 15 s.
…rts (#122)

* feat(api): limit requests, query size and recipe creation; batch inserts

- Per-client GraphQL request limit (300/min, keyed like the auth limiter
  behind Apache): 429 with Retry-After and code RATE_LIMITED.
- Validation rule rejecting operations with more than 10 aliases, 3
  top-level fields, 300 fields after fragment expansion or 8 levels
  (QUERY_TOO_COMPLEX) before any resolver runs. Introspection is not
  counted, so GraphiQL keeps working. Bodies over 1 MB are refused (413).
- Recipe creation quota per user: 30 per hour (RATE_LIMITED with
  retryAfterSeconds) and 1000 in total (QUOTA_EXCEEDED), checked under a
  per-user advisory lock so parallel creates are counted one by one.
- Ingredients, instructions and tags are written with one INSERT per
  table (unnest WITH ORDINALITY) instead of one per row.
- Limits are injectable through createApp; the browser test server
  raises the request limit since all scenarios share 127.0.0.1.
- The web client explains RATE_LIMITED (also HTTP 429) and QUOTA_EXCEEDED.

Closes #119

* fix(api): apply alias and root-field limits to introspection queries

Introspection fields (__schema, __type) were skipped entirely by the
query limits, so a large aliased introspection query could repeat the
whole schema without limit. They now count like any other field for
aliases, top-level fields and total size, which also bounds fragment
expansion inside them. Only depth is exempt, because GraphiQL's standard
introspection query is 15 levels deep (about 230 fields, no aliases) and
still passes.

Tests: the standard getIntrospectionQuery() is accepted; aliased
__schema/__type at the top level, aliases below __schema and a very
large nested introspection query are rejected.

* fix(api): enforce the body limit on bytes received, not just Content-Length

The 1 MB limit only looked at the Content-Length header, so a chunked
request without it (or one that sent more than it stated) was parsed at
any size. The request body is now read through a stream that counts the
bytes actually received and fails once over the limit; the request is then
answered with 413 and PAYLOAD_TOO_LARGE. The quick Content-Length
rejection stays, so honest oversized requests are still refused before
any reading.

Test: a chunked POST without Content-Length over 1 MB gets 413, and a
small chunked POST still succeeds.

* fix(api): count a request toward the rate limit only after CSRF checks pass

Requests were counted before the CSRF header and content-type checks, so
a stream of requests that were refused anyway (403) could use up a
client's whole per-minute budget and lock them out. The checks now run
first and the request is counted only when they pass, so refused
requests cost the client nothing.

Test: repeated requests with a wrong header, a wrong content-type or an
oversized Content-Length are refused, and the client's full budget is
still available afterwards.

* fix(api): count __typename in query limits; validate GET queries before rate limiting

- __typename now counts toward the total field and alias limits, so a
  fragment chain of __typename cannot expand to 2^n fields unchecked. It
  still does not count as a top-level field or as nesting.
- A GET that carries a query needs the same X-Requested-With header as a
  POST. Only requests that run an operation are counted toward the request
  limit, so malformed or cross-site GETs cannot use up a visitor's quota.
hasanmo and others added 8 commits November 18, 2026 12:56
Co-authored-by: hasan.fawzi <hasan.fawzi@hoglund.no>
Co-authored-by: hasan.fawzi <hasan.fawzi@hoglund.no>
* docs(api): explain request handling and recipe repository

* docs(api): correct authentication and lock-order explanations

---------

Co-authored-by: hasan.fawzi <hasan.fawzi@hoglund.no>
Co-authored-by: hasan.fawzi <hasan.fawzi@hoglund.no>
* docs(readme): simplify navigation and local setup

* docs(readme): add evaluation demo account
* fix(cookbook): restore recipe list navigation and improve search

* test(cookbook): verify return links in browser journeys

* fix(search): preserve pending input across sort and filter changes

---------

Co-authored-by: Oliver Ørjavik <136926544+orjavik@users.noreply.github.com>
@oliveror oliveror requested a review from a team as a code owner November 20, 2026 15:03
Oliver Ørjavik and others added 2 commits November 20, 2026 16:04
The squash merge from PR #66 has the same tree as ca08816, which is already in dev history. Keep the current dev tree, including all changes added since that snapshot.
Co-authored-by: Oliver Ørjavik <136926544+orjavik@users.noreply.github.com>
@oliveror oliveror merged commit 12efe16 into main Nov 21, 2026
2 checks passed
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants