feat(adapters): add defineAdapter for uniform framework integrations#71
Open
johnstonmatt wants to merge 4 commits into
Open
feat(adapters): add defineAdapter for uniform framework integrations#71johnstonmatt wants to merge 4 commits into
johnstonmatt wants to merge 4 commits into
Conversation
commit: |
JSR rejects destructured exports and exports without explicit type
annotations in the public API. Return `withSupabase` directly from
`defineAdapter` (instead of `{ withSupabase }`) and annotate each
adapter's exported `withSupabase` with `AdapterWithSupabase<...>`.
…55/defineAdapter-for-uniform-integrations
Brings the NestJS adapter under the same `defineAdapter` factory used by Hono, H3, and Elysia. The one-arg guard class behavior is unchanged; the two-arg dual-mode handler (`Request | ExecutionContext`) is added for parity with the other adapters. NestJS intentionally omits `getExistingContext` — guards run in global → controller → handler order, so a handler-level guard must always re-evaluate to override what an outer guard set.
johnstonmatt
added a commit
that referenced
this pull request
May 28, 2026
PR #71 (on FUNC-655/defineAdapter-for-uniform-integrations) is the source of truth for the `defineAdapter` API and lands first. Match its shape on this branch so that once #71 merges to main, no breaking change ripples through to gates-core consumers: - `defineAdapter(spec)` returns the overloaded `withSupabase` function directly (was: `{ withSupabase }`). - Adapters annotate the export explicitly: `export const withSupabase: AdapterWithSupabase<Ctx, M> = defineAdapter<...>({...})` (was: `export const { withSupabase } = defineAdapter<...>({...})`). The annotation duplication is the price of JSR slow-type compatibility without the wrapping object. Same trade-off PR #71 already made; this just keeps the public surface uniform across branches.
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.
This pull request introduces a new, unified adapter pattern for Supabase server framework integrations, specifically refactoring and enhancing the Elysia and H3 adapters, and updating the package exports to expose a shared adapter interface. The main changes add a dual-form
withSupabaseAPI to both Elysia and H3 adapters, allowing either plugin/middleware or direct route handler usage, and ensure consistent error handling and context reuse across frameworks. Comprehensive tests are added for the new handler form in Elysia, H3, and Hono. Package exports are updated to expose the new core adapter interface.Adapter architecture and API improvements
Refactored the Elysia (
src/adapters/elysia/plugin.ts) and H3 (src/adapters/h3/middleware.ts) adapters to use a newdefineAdapterutility fromcore/adapters, enabling a unified, dual-formwithSupabaseAPI. This API supports both plugin/middleware form and direct route handler form, with consistent error handling and context reuse. [1] [2] [3] [4] [5] [6]Enhanced documentation in both adapters to clearly explain the new dual-form API, usage patterns, and error handling expectations. [1] [2] [3]
Testing enhancements
withSupabasehandler usage in Elysia (plugin.test.ts), H3 (middleware.test.ts), and Hono (middleware.test.ts), covering context reuse, error propagation, and direct Web Fetch compatibility. [1] [2] [3]Package and export updates
jsr.jsonandpackage.jsonto export the newcore/adaptersinterface, making the adapter utility available for framework integrations. [1] [2]Documentation and changelog
CHANGELOG.mdfor consistency.References: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]