Repository navigation
Forward RERUM Pagination-* headers from /query - #132
Conversation
Review: works; consider deriving headers dynamicallyThe implementation correctly resolves #131: headers survive both the 200 and 502 paths, no headers are invented when RERUM doesn't send them, and the tests cover forwarding, absence, and over-forwarding. I like the explicit test that the rejected-fetch path adds no pagination headers. One suggestion: the fixed PAGINATION_HEADERS list mirrors the upstream contract precisely, which protects canonical casing, but it also means TinyNode has to be updated if RERUM ever adds another pagination header. Could this route interpret the headers instead — for example, iterate Tiny note from reading est/routes/query.test.js: paginationHeaders is camelCase but tested against Express-lower-cased response keys. The variable name is slightly misleading; consider expectedHeaderKeysLower or similar. Question on the deployment side: the upstream PR (#310) removes the RERUM_ prefix from MAX_QUERY_LIMIT / MAX_QUERY_SKIP. That changes the namespace for existing deployments. Is there a migration step or alias planned so that environments that already set RERUM_MAX_QUERY_* don't silently fall back to defaults? |
Going to leave the PAGINATION_HEADERS technique as-is. We could just forward all headers, and I think at one point in time that is what we did. I'll make a new issue about forwarding RERUM headers. Dev and Prod both have the correct .env settings. The code was the thing that had it wrong. |
Summary
Resolves #131.
RERUM rerum_server_nodejs#310 reports pagination on
/queryin four response headers.TinyNode read only the body and built a fresh response, so the headers were dropped.
/querynow copies anyPagination-Limit,Pagination-Skip,Pagination-Limit-Max, andPagination-Skip-Maxheader RERUM returns onto its own response.The copy happens before branching on
resp.ok, so the headers survive on both the200and the502.A fixed list of names is used rather than a
pagination-prefix scan, which keeps the canonical header casing and forwards only the documented contract.Access-Control-Expose-Headersis already*, so no CORS change is needed.What changed
routes/query.jsPagination-*headers before theresp.okbranchtest/routes/query.test.jsheaders: new Headers(); new tests for forwarding on success, forwarding on error, absence, and no over-forwarding; the rejected-fetch test asserts no pagination headersVerification
npm run allTests: 84 unit and 5 e2e tests pass, 0 failed, 0 skipped.Against TinyNode running locally on a RERUM built from #310, body
{"type":"Annotation"}:200, 100/0/500/100000200, none200, 10/0/500/100000?limit=25&skip=5200, 25/5/500/100000200, none200, 25/5/500/100000?limit=1000200,Pagination-Limit: 500200, none200,Pagination-Limit: 500?skip=100001400, both-Max502, none502, both-Max?limit=1e3400, both-Max502, none502, both-Max/app/query?limit=1000200, none/queryTinyNode's default limit is 10, so no params reports
Pagination-Limit: 10.A cross-origin browser
fetchfromlocalhost:3001to TinyNode onlocalhost:3002read all four headers on the200and both-Maxheaders on the502.Out of scope
limit/skipcheck is looser than RERUM's new one.?limit=1e3and?limit=0pass TinyNode, RERUM rejects them, and the client gets a502(now with the-Maxheaders).?limit=-1is rejected by TinyNode before RERUM is called, so its400carries no pagination headers. Aligning the two is worth its own issue.502body echoes the internal RERUM URL. This is existing behavior.