Skip to content

sub-issue: Create export-contacts edge function #2812

@malek10xdev

Description

@malek10xdev

Relates to #2750 — Phase 2 migration.

Goal

Move contact export (CSV, VCard, Google Contacts) from Express backend to a new export-contacts edge function.

Endpoint

Method Path Purpose
POST /:type Export contacts (csv/vcard/google_contacts) with credit verification

Key challenges

  • Billing flow: Port credit verification including 402 (no credits), 266 (confirm partial), 206 (partial content) responses
  • File generation: CSV and VCard generators are pure functions, portable
  • Google Contacts API: Uses OAuth access token from mining sources
  • Rate limiter: Replace express-rate-limit (100 req/15min)

Files to create

  • supabase/functions/export-contacts/index.ts — Hono app
  • supabase/functions/export-contacts/formats/ — CSV, VCard, Google Contacts generators

Files to modify

  • frontend/src/components/mining/buttons/ExportContacts.vue

Files to remove

  • backend/src/routes/contacts.routes.ts:29-34
  • backend/src/controllers/contacts.controller.ts:207-273
  • backend/src/services/export/ (entire directory)

Acceptance criteria

  • CSV export works from edge function with billing
  • VCard export works from edge function with billing
  • Google Contacts export works with OAuth access
  • Credit verification (402/266/206) responses work correctly
  • Frontend calls edge function directly
  • 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