Feat/Community Backend — feed, posts, comments, likes, leaderboard#256
Open
thoran123 wants to merge 3 commits intoGopher-Industries:masterfrom
Open
Feat/Community Backend — feed, posts, comments, likes, leaderboard#256thoran123 wants to merge 3 commits intoGopher-Industries:masterfrom
thoran123 wants to merge 3 commits intoGopher-Industries:masterfrom
Conversation
- 7 new endpoints under /api/community - DB-first with bundled seed + in-memory fallback so frontend never blocks - Standardized response envelope (matches support PR) - 17 hermetic Jest tests - Optional migration: migrations/create_community_tables.sql Backs frontend tasks M-60 through M-63 (FeedScreen, PostDetailScreen, CreatePostScreen, LeaderboardScreen).
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.
Why
The mobile community screens (
FeedScreen,PostDetailScreen,CreatePostScreen,LeaderboardScreen— frontend tasks M-60 through M-63) need backend endpoints that don't exist yet. This change adds the nine endpoints they need, with sensible defaults so the UI never sees a blank state.What this PR adds
New endpoints
Acceptance criteria coverage
page/pageSizequery params,hasMorein response?page=1POST /posts/:id/commentsreturns the new commentPOST /api/upload)weekly/monthly/all_timecurrentUserRankfield in responseBehaviour with no DB
If the Supabase tables don't exist yet, every read returns seed content and every write goes into an in-memory store that resets on server restart. The response includes
meta.source: 'seed'/meta.persistedTo: 'memory'so this state is observable.When the migration is applied, the endpoints automatically switch to the DB on the next request — no code change, no redeploy.
Tests
Mocks
dbConnection.jsand the auth middleware to keep the suite hermetic. Run alongside the support suites to confirm no regressions:(32 / 32 passing.)
Risks / rollout
/api/community. Nothing else calls it.authenticateTokenmiddleware — no new auth code paths./api/uploadroute, which already validates mime type and size.