refactor(deco-apps): delegate to the shared Supabase REST helper - #6166
Open
pedrofrxncx wants to merge 1 commit into
Open
refactor(deco-apps): delegate to the shared Supabase REST helper#6166pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
deco-apps.ts hand-rolled its own fetch + check-and-throw Supabase REST call (supabaseGetApps) with a second, redundant 10s timeout constant — the exact fetch/error-handling shape apps/api/src/deco-legacy/supabase.ts already generalizes as supabaseGet(url, key, path). Delegates to it instead. -25/+5 net. Behavior preserved: same query string, same thrown Error message on a non-ok response (only the console.error log line is slightly less verbose, since supabaseGet doesn't truncate the response body). Confirmed with the existing deco-apps.test.ts (mapSupabaseAppRows + auth-guard tests), which cover this file and don't hit the network path.
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.
Source: C1 dedup —
apps/api/src/api/routes/deco-apps.tshand-rolled its ownfetch+ check-and-throw Supabase REST call (supabaseGetApps), duplicating the exact patternapps/api/src/deco-legacy/supabase.ts'ssupabaseGet(url, key, path)already generalizes (this is the same fetch/error-handling shape the repo has consolidated once before, per thedeco-legacybug hunt this tick).Why a maintainer wants it: one fewer hand-rolled HTTP client to keep in sync with the shared one — this local copy had drifted to a second, redundant 10s timeout constant instead of reusing the shared 15s
REQUEST_TIMEOUT_MS. Fewer near-duplicate fetch wrappers means fewer places a future auth/timeout/error-shape fix has to be applied twice.Net line delta: -25 / +6 (removed the local
supabaseGetAppsfunction and its dedicated timeout constant, replaced the one call site withsupabaseGet<SupabaseAppRow>(...)).Behavior confirmed unchanged: same REST query string (
apps?select=name,title,description,logo,category,vendors(alias,url)), same thrownError("External service error (<status>)")on a non-2xx response, same502surfaced to the caller. The only difference is theconsole.errorlog body is no longer truncated to 200 chars (supabaseGet logs the full response text) — a log-verbosity change, not a behavior change.Command a reviewer runs:
bun test apps/api/src/api/routes/deco-apps.test.ts(coversmapSupabaseAppRowsand the auth-guard route, unaffected by this change) andcd apps/api && bunx tsc --noEmit.Verified locally:
bun run fmt,cd apps/api && bunx tsc --noEmit(clean),bun test apps/api/src/api/routes/deco-apps.test.ts(2 pass),bunx oxlint apps/api/src/api/routes/deco-apps.ts(0 warnings/errors). Full CI validates the rest.Summary by cubic
Delegates the
deco-appsSupabase REST call to the sharedsupabaseGethelper to remove a duplicate fetch + timeout implementation. Behavior stays the same; only logs now include the full response body instead of a 200‑char truncation.supabaseGetAppsand its 10s timeout; uses the shared 15sREQUEST_TIMEOUT_MSviasupabaseGetfromapps/api/src/deco-legacy/supabase.ts.502on non-2xx responses.apps/api/src/api/routes/deco-apps.tsonly; no migrations required.bun test apps/api/src/api/routes/deco-apps.test.tsandcd apps/api && bunx tsc --noEmit.Written for commit 0798559. Summary will update on new commits.