feat: flat pipeline syntax — mw(config) returns an Entry directly - #9
Merged
Conversation
commit: |
This was referenced Jul 1, 2026
johnstonmatt
approved these changes
Jul 2, 2026
Collaborator
|
awesome! |
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.
Summary
Adds
pipeline()and flat entry syntax to@supabase/web-middleware.pipeline(entries, handler)composes an ordered list of middleware entries around a handler. Each entry is created by calling a middleware with its config — no handler argument:mw(config)with no handler returns anEntry— the unit thatpipelineaccepts. The rule: if the last argument is not a function, return anEntry.What changed
src/core/types.ts—Entry<Key, In, Contribution>andConfigArgs<Config>added here so bothdefineMiddlewareandpipelinecan import themsrc/core/define-middleware.ts— added config-only overload:mw(config)→Entrysrc/core/pipeline.ts— new file;pipeline(entries, handler)folds entries right-to-left so the first entry is outermostsrc/core/pipeline.test.ts— new test fileTry it
Merge order
middlewareoption consumes this PR via a pkg.pr.new preview (@supabase/web-middleware@9); after this merges and publishes, #88's dependency must be repointed to the npm version.middlewareon the server,pluginsfor client namespaces) but has no code dependency in either direction.