feat(crud): migrate user, admin, and search APIs to Supabase#6
Merged
cH0NKIIs34L merged 3 commits intomainfrom Apr 11, 2026
Merged
feat(crud): migrate user, admin, and search APIs to Supabase#6cH0NKIIs34L merged 3 commits intomainfrom
cH0NKIIs34L merged 3 commits intomainfrom
Conversation
The previous userApi fetched from Express endpoints that will be
removed in Epic 4. This replaces both methods with direct
supabase.from('users') queries, and updates ProfilePage to
consume the { data, error } return shape instead of response.ok.
The previous adminApi fetched from Express endpoints that will be
removed in Epic 4. This replaces all three methods with direct
supabase.from('users') queries, and updates UserManagementPage
and UserRow to consume the { data, error } return shape.
The previous searchApi fetched from an Express search endpoint that
will be removed in Epic 4. This replaces it with a direct
supabase.from('users') query with dynamic filters, ilike for
partial username matching, date range filters, and a whitelisted
sort column to prevent injection. SearchPage is updated to consume
the { data, error } return shape.
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
Replace all Express-backed CRUD API modules with direct Supabase
queries so the client no longer depends on the server for data access.
What Changed
user.api.js— replaced fetch with supabase.from('users') queries;getProfile reads session uid, getById queries by UUID
admin.api.js— replaced fetch with supabase.from('users') queriesfor getAllUsers, promoteUser, and demoteUser
search.api.js— replaced fetch with a dynamic Supabase query chainsupporting ilike, eq, gte, lte, and whitelisted order
ProfilePage.jsx— updated to consume { data, error } shape; columnrefs updated to snake_case (created_at, last_login)
UserManagementPage.jsx— updated to consume { data, error } shapeUserRow.jsx— updated to consume { error } from adminApi; datefield updated to created_at (snake_case)
SearchPage.jsx— updated to consume { data, error } shapeWhat
This PR replaces
userApi,adminApi, andsearchApiwith SupabaseCRUD equivalents and updates all consuming components accordingly.
Why
The Express server routes for user, admin, and search will be deleted
in Epic 4. Migrating the API modules now ensures the client is fully
decoupled from the server before the cleanup happens.
How
client/src/lib/supabase.jsand build query chains directly — no fetch, no BASE_URL
userApi.getProfile()reads the active session uid viasupabase.auth.getSession()before querying, rather than relyingon a server session cookie
adminApipromote/demote use.update().eq().select().single()sothe updated row is returned in the same shape as before
searchApibuilds the query chain conditionally — each filter isonly appended when a value is present, preserving the existing
URL-state behaviour in SearchPage unchanged
to
.order()— same injection protection as the old Prisma layercreated_at,last_login) replace theold camelCase Prisma aliases throughout consuming components
_chainref pattern to avoid re-creating the mock per methodTesting
in isolation, sort fallback for invalid values, and error shape
SearchPage) will need mock updates in Epic 5 (Issue #15)
Pre-Merge Checklist
mainbefore opening this PRnpm testin bothclient/andserver/)console.logleft in production codenpm run lint)