Skip to content

sub-issue: Create mining-sources edge function (OAuth flow) #2809

@malek10xdev

Description

@malek10xdev

Relates to #2750 — Phase 1 migration.

Goal

Create a new mining-sources Supabase Edge Function (Hono-based) that handles OAuth URL generation and callback for Google/Microsoft providers. Consolidate the duplicated OAuth clients currently in both the Express backend and fetch-mining-source edge function.

Endpoints

Method Path Purpose
POST /:provider Generate OAuth authorization URL with state
GET /callback/:provider Exchange OAuth code for tokens, upsert source

Files to create

  • supabase/functions/mining-sources/index.ts — Hono app
  • supabase/functions/mining-sources/oauth-handler/ — move from fetch-mining-source

Files to modify

  • frontend/src/utils/oauth.ts
  • frontend/src/pages/sources.vue
  • frontend/src/components/campaigns/CampaignComposerDialog.vue

Files to remove

  • backend/src/services/OAuth2/ (entire directory)
  • backend/src/controllers/mining.controller.ts:192-241
  • backend/src/routes/mining.routes.ts:40-48

Acceptance criteria

  • OAuth URL generation works from edge function (no Express dependency)
  • OAuth callback exchanges code, upserts source, redirects to frontend
  • Frontend calls edge function directly via $saasEdgeFunctions
  • All Express OAuth code removed
  • Existing tests pass

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions