Skip to content

Add feed endpoints#1242

Open
clementbiron wants to merge 48 commits into
mainfrom
add-feed-endpoints
Open

Add feed endpoints#1242
clementbiron wants to merge 48 commits into
mainfrom
add-feed-endpoints

Conversation

@clementbiron
Copy link
Copy Markdown
Member

@clementbiron clementbiron commented Apr 29, 2026

This pull request adds Atom feed endpoints to the collection API so consumers can subscribe to recent terms updates. A new /feed endpoint exposes a collection feed, with variants at /feed/:serviceId and /feed/:serviceId/:termsType.

Contrary to what was discussed in #1238, each entry's primary alternate link points to the GitHub commit rather than to the version API. While testing the feed in real readers, a link resolving to a JSON document felt unhelpful for human consumers, who expect to land on a readable page. The version API is still exposed alongside as a related link, so programmatic consumers can discover it from the feed.

Update: each entry now exposes a single alternate link. By default it points to the version API, which works for any storage backend. Operators who want feed readers to land on a human-readable page can configure collection-api.feed.versionUrlTemplate (e.g. https://github.com/openTermsArchive/demo-versions/commit/%VERSION_ID); the placeholder is interpolated with the version's identifier.

Comment thread src/archivist/recorder/repositories/git/index.js Outdated
Comment thread src/collection-api/routes/feed.js Outdated
Comment thread src/collection-api/routes/feed.js Outdated
Comment thread src/collection-api/routes/feed.js Outdated
Comment thread src/collection-api/routes/feed.js Outdated
Comment thread src/collection-api/routes/feed.js Outdated
Comment thread src/collection-api/routes/feed.js Outdated
Ndpnt added 17 commits May 12, 2026 17:47
Filter documents at query time using the existing isTechnicalUpgrade
field when the option is disabled, in findAll, findByService and
findByServiceAndTermsType.
Feed subscribers want to be notified of changes in the legal content
of services, not of re-renderings of existing snapshots with updated
extraction rules. Pass includeTechnicalUpgrades: false to all three
versions repository queries used by feed routes.

Drop the now-dead technical-upgrade branches in classifyRecordType
and buildEntryTitle, and update tests accordingly.
Feed tag URIs (RFC 4151) and entry IDs are built by interpolating
collection.metadata.id. When this value is missing, the resulting IDs
contain double colons and become technically malformed URIs without
any feedback to the operator. Throw explicitly at apiRouter setup so
the misconfiguration is caught at boot rather than silently emitted in
every feed response.
The feed route no longer imports anything from the git repository
implementation: titles come straight from the record. Atom-only labels
(record-type categories) remain local to the route.
Falling back to new Date() when no entries exist made the feed-level
updated value change on every request, which breaks conditional GET:
readers would never see a 304 even when nothing changed. Use the Unix
epoch as a stable, RFC-valid placeholder until the first entry lands.
Atom feeds are typically polled every few minutes by RSS readers.
Setting Last-Modified from the latest entry's fetch date lets Express
honour If-Modified-Since and return 304 when nothing changed, saving
the cost of building and shipping the XML body for the (frequent)
unchanged case.
@Ndpnt Ndpnt force-pushed the add-feed-endpoints branch from 149ef2b to 0557e63 Compare May 12, 2026 15:48
Ndpnt added 3 commits May 12, 2026 17:50
Xml-js does not escape attribute values
Pass escapeXmlAttribute through xml-js's attributeValueFn rather than
wrapping each attribute manually. Escaping now happens at the
serialization boundary for every attribute, including those we did
not explicitly wrap before
@Ndpnt Ndpnt force-pushed the add-feed-endpoints branch from 0557e63 to f2eea3a Compare May 12, 2026 15:50
@Ndpnt Ndpnt force-pushed the add-feed-endpoints branch from 650567b to f8a90d2 Compare May 13, 2026 08:23
@Ndpnt Ndpnt force-pushed the add-feed-endpoints branch from 471473d to c857bc2 Compare May 13, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants