/gog/id/:_id expand endpoint for GoG Data#280
Open
thehabes wants to merge 4 commits into
Open
Conversation
thehabes
marked this pull request as ready for review
July 17, 2026 16:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a server-side expansion endpoint so clients can fetch an object with its describing Annotations already merged, instead of expanding on the client. This is the back-end half of the coordinated fix for glossing-entries CenterForDigitalHumanities/glossing-entries#310 ("Too Many Glosses for
localStorage").Paired front-end PR: CenterForDigitalHumanities/glossing-entries#319.
Problem
The Gallery of Glosses list expands every Gloss on the client: fetch the object, query every Annotation targeting it, then merge the Annotation bodies onto it. To avoid paying that 6–10 minute cost on every visit, expanded objects were cached in the browser's
localStorage, which overflowed the ~5 MB quota and broke the page. The chosen fix (option 2 in the issue) is to expand on the server behind a stable, browser-cacheable URL.Changes
GET /gog/id/:_id(routes/_gog_id.js, mounted inapp.js) →controller.expandedId. Namespaced under/gograther than overloading the genericGET /v1/id/:_idobject route.expandedIdhandler (controllers/gog.js): looks the object up by_id/slug (same lookup asGET /v1/id/:_id), runsexpand(), and responds with the same caching headers as the id route —Cache-Control: max-age=86400, must-revalidateandLast-Modified— so the stable URL is cached by the browser for 24h.expand()and exportedexpandedIdthroughdb-controller.js.{ value, source, evidence }to match DEER's client-sidebuildValueObject, and repeated keys collect into an Array — so the front end reads the server-expanded object exactly as it read the old client-expanded one (e.g.gloss.text.value.textValue).The endpoint accepts any RERUM id. It merges every current Annotation of type
Annotation/oa:Annotationtargeting the object (matching bothhttp/httpstargets), with no GENERATOR/CREATOR filter, matching the client's historicalexpand()behavior.Notes and follow-ups
/gog/id/:_id(was/v1/id/:_id/expanded) so it does not overload the generic object route. This still doesn't stop anyone from using/gog/id/:_idto expand their own data — restricting it to GoG data would need an additional guard (e.g. gating on__rerum.generatedBy/ GENERATOR)./gog/id/:_iddo not include a Bearer agent, so they can't pull Annotations for just the app making the request (it isn't provided). It pulls from all existing Annotations targeting the entity no matter which app made the Annotations. We could design an optional way for an app agent to be provided.