Repository navigation
Add a JSON API for the mobile and desktop apps - #13
Merged
Merged
Conversation
The apps used the old Next.js REST routes (/api/posts, /api/vote, ...), which went away with the TanStack Start rewrite, so the shipped app can no longer load or write anything. The apps now read public data straight from Appwrite. For writes and the signed-in person's votes they call /api/app/* with an Appwrite JWT: each route verifies it the way establishSession does, then runs the same castVote, createComment, removeComment, createPost and syncProfile the website uses, so rate limits, counters and notifications stay in one place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RefetchProject ID: Functions (4)
Tip MCP server integration brings LLM superpowers to Claude Desktop and Cursor IDE |
CI's format:check fails on main because of these two files; this is prettier --write on them and nothing else. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.


The Flutter app (refetch-io/refetch_flutter) read and wrote through the old Next.js REST routes (
/api/posts,/api/vote, ...). They went away with the TanStack Start rewrite, so the shipped app shows "Request failed, HTTP 404" on every feed.What this adds
/api/app/*, documented indocs/APP_API.md:POST /api/app/sessionsyncProfile(call after sign-in)POST /api/app/votecastVotePOST /api/app/votesgetUserVotesfor posts and commentsPOST /api/app/commentscreateCommentDELETE /api/app/comments/:idremoveCommentPOST /api/app/submitcreatePostEach route takes
Authorization: Bearer <Appwrite JWT>, verifies it withaccount.getthe wayestablishSessiondoes, and then calls the same server function the website's server functions call, so rate limits, duplicate checks, counters and notifications stay in one place. The app reads public data (feeds, stories, comments) straight from Appwrite and only uses these routes for writes and the viewer's own votes.Validation and the response mapping live in
src/lib/app-api.ts(unit tested); request handling is insrc/server/app-api.server.ts.routeTree.gen.tsis regenerated.Checks
pnpm test: 122 passed (9 new insrc/lib/app-api.test.ts)pnpm typecheck: cleanvite preview): every route answers 401 with no token and with a forged JWT (verified against Appwrite)Release order
This must be deployed before the app's next release (refetch_flutter 0.2.0+6), which calls these routes for votes, comments and submissions.
🤖 Generated with Claude Code