Conversation
…routes - Add nango_connections supabase migration table - Add OwnedNangoProxy + OwnedNangoHttpClient to nango crate - Add NangoIntegrationId trait with GoogleCalendar/GoogleDrive marker types - Add NangoConnection<I> axum extractor (resolves connection_id from DB) - Extend webhook handler to upsert/delete nango_connections - Refactor api-calendar to use NangoConnection<GoogleCalendar> - Refactor api-storage to use NangoConnection<GoogleDrive> - Remove connection_id from request bodies (server-side lookup) - Remove duplicated config.rs/state.rs from api-calendar and api-storage Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
✅ Deploy Preview for hyprnote-storybook canceled.
|
❌ Deploy Preview for hyprnote failed.
|
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
…cess comment Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
…ssing config in webhook Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
…o-connection-extractor
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.
feat: add NangoConnection<I> extractor for nango-powered integration routes
Summary
Introduces a generic
NangoConnection<I>axum extractor that resolves a user's Nangoconnection_idfrom a Supabasenango_connectionstable, removing the need for clients to passconnection_idin every request body. The extractor uses marker types for type-safe integration identification.Key pieces:
nango_connectionstable) — storesuser_id ↔ connection_idper integration, populated by webhookOwnedNangoProxy+OwnedNangoHttpClientincrates/nango— owned variants to solve lifetime issues in extractors; shared header logic extracted toapply_proxy_headersNangoIntegrationIdtrait +GoogleCalendar/GoogleDrivemarker types incrates/api-nangoNangoConnection<I>extractor — readsAuthContextfor user_id, queries Supabase PostgREST for connection_id, builds ready-to-use HTTP clientsupabase_service_role_keyis not configuredSupabaseClientextracted intosupabase.rswith URL-encoded query params andon_conflict=user_id,integration_idfor correct upsert behaviorconnection_idremoved from all request bodies, duplicatedconfig.rs/state.rsdeletedBefore → After (handler example):
Updates since last revision
supabase_service_role_keyserde conflict: TheEnvstruct inapps/api/src/env.rshad an explicitsupabase_service_role_key: Option<String>field that shadowed the same field inside#[serde(flatten)] SupabaseEnv, which would have crashed the API server on startup. Removed the duplicate and now usesenv.supabase.supabase_service_role_keydirectly.SupabaseClient::is_configured()before attempting DB operations. Ifsupabase_service_role_keyis not set, it logs a warning and returns 200 (no Nango retries for a config issue). Transient DB failures still return 500 so Nango retries.calendar::router(),nango_connection_stateextension layer).successgate documented: Added comment explaining why we checkpayload.successbefore deleting local state on deletion webhooks — avoids removing a valid local record if revocation failed on Nango's side (per Nango webhook docs, successful deletions setsuccess: true).Review & Testing Checklist for Human
connection_idis removed from all calendar/storage request bodies. No frontend changes are included in this PR — verify that callers are updated or that this is intentional for the new OAuth flow.NangoConnectionStateis available to calendar/storage routes — the.layer(Extension(...))is added after.nest("/calendar", ...)and.nest("/nango", ...)inapps/api/src/main.rs, which in axum means it applies to all routes above it in the chain. Verify this is correct.end_user_id: The webhook handler passespayload.end_user.end_user_iddirectly to thenango_connectionstable'suser_id uuidcolumn with a FK toauth.users(id). Verify that the upstream Connect Session creation (step 3 of the OAuth milestone) will pass the Supabase user UUID asend_user.id.nango_connections→ call/calendar/calendarswith just auth token → verify it resolves connection and returns data.Notes
selectpolicy for security. Users can only read their own connections.list_calendarsis now a POST with no request body (just the extractor).OwnedNangoProxyduplicates method signatures fromNangoProxy— this is a known tradeoff to solve lifetime issues in axum extractors. Future proxy behavior changes need to be made in both places.Link to Devin run: https://app.devin.ai/sessions/4feb4eb6926b42c5b1c43ccca430802b
Requested by: @yujonglee