Skip to content

Refactor: Remove orphaned Supabase ai-chat edge function (Fixes #854)#977

Merged
durdana3105 merged 1 commit into
durdana3105:mainfrom
ArshVermaGit:fix-duplicate-edge-functions-854
Jun 15, 2026
Merged

Refactor: Remove orphaned Supabase ai-chat edge function (Fixes #854)#977
durdana3105 merged 1 commit into
durdana3105:mainfrom
ArshVermaGit:fix-duplicate-edge-functions-854

Conversation

@ArshVermaGit

@ArshVermaGit ArshVermaGit commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

This PR addresses the architectural technical debt outlined in issue #854 by completely removing the unused and fragmented Supabase ai-chat edge function. Because the client exclusively uses the custom Node.js Express backend (/api/ai/*) for OpenRouter AI integrations, the Edge Function was orphaned, creating duplicated logic (like token validation and prompt sanitization) and potential maintenance/security liabilities. By removing supabase/functions/ai-chat, this PR successfully enforces a single source of truth and strictly centralizes all API handlers within our Express backend.

Closes #854

Summary by CodeRabbit

  • Chores
    • Removed the AI-powered chat endpoint service that was previously available.

@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

@ArshVermaGit is attempting to deploy a commit to the durdana3105's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cfbf3f30-bc93-4989-b405-f7b2ddf1226c

📥 Commits

Reviewing files that changed from the base of the PR and between a65ed99 and 2618bbd.

📒 Files selected for processing (1)
  • supabase/functions/ai-chat/index.ts
💤 Files with no reviewable changes (1)
  • supabase/functions/ai-chat/index.ts

📝 Walkthrough

Walkthrough

The entire supabase/functions/ai-chat/index.ts file (252 lines) is deleted. This removes the Supabase Edge Function that handled CORS, Supabase JWT authentication, prompt validation, OpenRouter API calls, and error responses — logic that already exists in the Express backend.

Changes

Cohort / File(s) Summary
Remove orphaned Edge Function
supabase/functions/ai-chat/index.ts
Entire file deleted: removes CORS preflight handling, Bearer JWT auth via supabase.auth.getUser, prompt length validation, OPENROUTER_API_KEY env loading, OpenRouter chat completions API call, JSON response construction, and 500 error fallback.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 Snip snip, the extra code is gone,
Two paths to one truth — now just one!
No duplicate keys, no forking trail,
Express stands alone, it shall not fail.
One hop, one source, the warren's clean~ ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and concisely summarizes the primary change: removing an orphaned Supabase ai-chat edge function to address technical debt.
Linked Issues check ✅ Passed The code changes directly address issue #854 by removing the orphaned Supabase ai-chat edge function, consolidating API logic exclusively in the Express backend.
Out of Scope Changes check ✅ Passed The PR contains only the removal of the orphaned Supabase ai-chat edge function file, which is entirely within scope of issue #854's requirement to remove unused Edge Functions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@ArshVermaGit ArshVermaGit left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue resolved

@durdana3105 durdana3105 merged commit 7200d81 into durdana3105:main Jun 15, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fragmented Business Logic: Duplicate Edge Functions and Express Backend

2 participants