Conversation
- Add content negotiation to search.nim for Accept: application/json - Add toJson helper for Result[User] in json_api.nim - Add test for search JSON endpoint - Fix pre-existing build issues with httpcore imports and string conversion
- Add content negotiation to follow.nim for GET /following - Add toJson helper for following lists in json_api.nim - Add test for following lists JSON endpoint
- Add content negotiation to list.nim for GET /i/lists/<id> - Add toJson helper for List and Timeline in json_api.nim - Add test for list profile JSON endpoint
- Add content negotiation to status.nim for GET /<username>/status/<id> - Add toJson helper for Conversation in json_api.nim - Add test for single tweet JSON endpoint
- Add content negotiation to GET /pinned in nitter.nim - Add pinnedTweetsJson helper in json_api.nim - Add test for pinned tweets JSON endpoint
- Add acceptJson() template in router_utils.nim for consistent header detection - Replace 49 duplicate header check patterns across all route files - Simplifies maintenance - single source of truth for Accept header logic
- Remove duplicate POST /pin and POST /unpin handlers from nitter.nim (these are handled by the extended pinned router in routes/pinned.nim) - Remove GET /pinned handler from nitter.nim (handled by pinned router) - Add renderTweetHtml helper proc to json_api.nim - Add html field to tweet JSON output using renderTweet - Add toJson(tweet: Tweet; prefs: Prefs) overload for custom prefs - Update existing toJson(tweet: Tweet) to include html using defaultPrefs
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
Implements JSON API support via content negotiation for various endpoints in Nitter. Clients can now request JSON responses by sending
Accept: application/jsonheader.Completed Endpoints
Phase 1: Core Read-Only Endpoints
GET /- Home feedGET /<username>- User profileGET /<username>/with_replies- User repliesGET /<username>/media- User mediaPhase 2: Discovery & Search
GET /search- Search resultsGET /following- Following listsGET /i/lists/<id>- List profilePhase 3: User Content & Actions
GET /<username>/status/<id>- Single tweetGET /pinned- Pinned tweetsImplementation Details
Accept: application/jsonheaderFiles Changed
src/routes/*.nim- Added content negotiation to route handlerssrc/json_api.nim- Added toJson helpers for various typessrc/nitter.nim- Fixed pre-existing build issues, added pinned routetests/test_api_json.py- Added/updated testsTesting
Run the test suite:
Notes