Skip to content

Add a JSON API for the mobile and desktop apps - #13

Merged
lohanidamodar merged 2 commits into
mainfrom
feat/app-api
Nov 8, 2026
Merged

lohanidamodar merged 2 commits into
mainfrom
feat/app-api

Conversation

@lohanidamodar

Copy link
Copy Markdown
Collaborator

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 in docs/APP_API.md:

Route Runs
POST /api/app/session syncProfile (call after sign-in)
POST /api/app/vote castVote
POST /api/app/votes getUserVotes for posts and comments
POST /api/app/comments createComment
DELETE /api/app/comments/:id removeComment
POST /api/app/submit createPost

Each route takes Authorization: Bearer <Appwrite JWT>, verifies it with account.get the way establishSession does, 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 in src/server/app-api.server.ts. routeTree.gen.ts is regenerated.

Checks

  • pnpm test: 122 passed (9 new in src/lib/app-api.test.ts)
  • pnpm typecheck: clean
  • prettier: clean
  • Built server (vite 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

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>
@appwrite

appwrite Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Refetch

Project ID: 63ef1792594ff4f50de2

Sites (1)
Site Status Logs Preview QR
 App
688e6ad00039239f1ecc
Ready Ready View Logs Preview URL QR Code
Functions (4)
Function ID Status Logs
 Readme 68a18eba0012c97a0017 Failed Failed View Logs
 Scout 689bd7b6002c5d783925 Ready Ready View Logs
 Algorithm 689b8b5f00075917c520 Ready Ready View Logs
 Enhancement 6897c57600169dfb0b92 Ready Ready View Logs

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>
@lohanidamodar
lohanidamodar merged commit e27fd7f into main Nov 8, 2026
4 of 6 checks passed
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.

1 participant