Skip to content

Migrate IMAP boxes listing from backend to emails-fetcher + edge function#2854

Open
malek10xdev wants to merge 5 commits into
mainfrom
feat/imap-boxes-migration
Open

Migrate IMAP boxes listing from backend to emails-fetcher + edge function#2854
malek10xdev wants to merge 5 commits into
mainfrom
feat/imap-boxes-migration

Conversation

@malek10xdev

Copy link
Copy Markdown
Collaborator

Summary

Migrate the IMAP boxes folder listing from the legacy backend API (/api/imap/boxes) to the emails-fetcher microservice, proxied through the Supabase imap edge function. This removes backend dead code and moves IMAP logic closer to the email-fetching service.

Changes

  • feat: Add POST /api/imap/boxes endpoint to emails-fetcher — validates input, fetches IMAP credentials from mining source service, opens connection via ImapConnectionProvider, and returns the folder tree from ImapBoxesFetcher
  • feat: Add ImapBoxesFetcher + imapTreeHelpers to emails-fetcher — encapsulates IMAP folder tree building logic using imapflow
  • feat: Update supabase/functions/imap to Hono framework; add POST /boxes endpoint that proxies to emails-fetcher with user auth
  • feat: Migrate frontend leadminer store to call supabase.functions.invoke('imap/boxes') instead of backend API
  • chore: Remove deprecated backend/src/controllers/imap.controller.ts, backend/src/routes/imap.routes.ts, backend/src/services/imap/ImapBoxesFetcher.ts, and initializeImapRoutes from app.ts

Testing

  • All 592 unit tests pass (49 test suites)
  • Pre-push hooks: backend lint, frontend lint, prettier — all clean

Add a new POST /api/imap/boxes endpoint to the emails-fetcher that
retrieves the IMAP folder tree for a given email. The endpoint:
- Validates userId and email input
- Fetches IMAP credentials from the mining source service
- Opens an IMAP connection via ImapConnectionProvider
- Uses ImapBoxesFetcher to build the IMAP folder tree
- Properly handles connection cleanup in finally block
Migrate the IMAP edge function from raw Deno.serve to Hono framework.
Add POST /boxes endpoint that proxies IMAP folder listing requests to
the emails-fetcher microservice. Refactor /detect to use Hono routing.
Replace the backend API call (/api/imap/boxes) with a direct Supabase
edge function invocation (imap/boxes). Only requires email now, since
the edge function resolves the user ID from the auth token.
Remove the old backend IMAP controller, routes, and service for listing
IMAP boxes. This functionality has been migrated to:
- The supabase/functions/imap edge function (proxies to emails-fetcher)
- The micro-services/emails-fetcher microservice (actual IMAP logic)
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

Coverage Report

Passed

Commit: 5584ffe

Summary

Name Stmts Branch Funcs Lines
🟡 Total 45.4% 42.7% 52% 45.7%
All files
Name Stmts Branch Funcs Lines
🔴 backend/src/app.ts 0% 0% 0% 0%
No coverage changes
Name Stmts Branch Funcs Lines
🔴 backend/src/app.ts 0% 0% 0% 0%

Generated by Test Coverage Reporter for commit 5584ffe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant