feat(article): drop the markdown body from list responses - #213
Merged
Conversation
ArticleItemSchema served both the detail endpoint and every list endpoint, so GET /articles and GET /articles/me returned the full markdown of every item. The schema caps a body at 100 000 characters, which makes a page of fifty articles megabytes of text no list view renders. Measured against a single 28 KB article: the list page went from 28 930 to 924 bytes. At limit=50 that is roughly 1.4 MB versus 46 KB, and the larger payload was also what Redis cached for 60 seconds per viewer. ArticleSummarySchema is an Omit of the item schema rather than a hand-written twin, and toSummaryResponse now holds every shared field with toResponse spreading the body onto it, so the two shapes cannot drift apart. Narrowing toListResponse propagates through the controller into the route generics, so the type system enforces this rather than fast-json-stringify quietly dropping a field. The repository selects and the Redis cache DTO are deliberately untouched. The repo uses include rather than select, so removing body there would break the ArticleWithRelations cast and Article.with, which requires a body. And stripping body from CachedArticle would feed an empty string into the entity: if a body ever returns to a list response, cached pages would serve "" while uncached pages served real markdown - a bug that appears and disappears on a 60 second cycle. Both belong in a separate change with an explicit summary read model. Doing this now costs nothing: the article migrations are not yet applied to production, so no client is reading these responses. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 25, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 25, 2026
# [1.7.0](v1.6.0...v1.7.0) (2026-08-25) ### Features * **article:** drop the markdown body from list responses ([#213](#213)) ([628d897](628d897)) * **profile:** expose published articleCount on the profile response ([#214](#214)) ([1b030bf](1b030bf)) ### Performance Improvements * **profile:** resolve follower list targets without loading the full profile ([#215](#215)) ([b855269](b855269))
|
🎉 This PR is included in version 1.7.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
What does this PR do?
ArticleItemSchemaserved both the detail endpoint and every list endpoint, soGET /articlesandGET /articles/mereturned the full markdown of every item. The schema caps a body at 100 000 characters, which makes a page of fifty articles megabytes of text no list view renders — and that was also what Redis cached for 60 seconds, per viewer.Measured
Booted the app against the dev database with one 28 KB article:
GET /articles?limit=10GET /articles/:slugAt
limit=50that is roughly 1.4 MB versus 46 KB per page.How
ArticleSummarySchema = FBType.Omit(ArticleItemSchema, ["body"])— derived, not a hand-written twin, so a field added to the item schema appears here automatically.ArticleSummaryResponse = Omit<ArticleResponse, "body">in the mapper, withtoSummaryResponseholding every shared field andtoResponsespreadingbodyonto it. One place to change, so the two shapes cannot drift.toListResponse's return type propagates throughArticleController.list/mineinto the routeReplygenerics — so the type system enforces this, rather than fast-json-stringify quietly dropping a field it does not recognise.The detail, create, update, publish and archive responses are untouched and still carry the body.
What is deliberately not touched
The repository selects. The repo uses
include, notselect, sobodyis still fetched from Postgres. Removing it there means switching toselect, which breaks theArticleWithRelationscast andArticle.with(), which requiresbody: string. That cascades into either an optional body on the domain entity or a second read model — real work, unrelated to this.The Redis cache DTO. Stripping
bodyfromCachedArticlewould feed an empty string intoArticle.with(). If a body ever returns to a list response, cached pages would serve""while uncached pages served real markdown — a bug that appears and disappears on a 60-second cycle. Both belong in one later change with an explicit summary read model.Timing
Doing this now costs nothing: the article migrations have not been applied to production, so no client is reading these responses yet. Later, it would be a breaking change.
Verification
lint,format:check,buildclean; 755 unit tests pass.Three new e2e assertions in
tests/e2e/article/read.test.ts: list items carryexcerpt,coverImageUrlandreadingTimeMinutesbut notbody;/articles/melikewise; and the detail endpoint still returns a non-emptybody.Verified end to end by booting the real app: create → publish → list → detail → the numbers in the table above.
Type of Change
Checklist
feature/,fix/,chore/,docs/)First of three: this one lands before the profile
articleCountso the profile Articles tab is never shipped against megabyte pages.🤖 Generated with Claude Code