feat: add middleware meta support and defineMiddlewareRoute utility#1154
Draft
productdevbook wants to merge 2 commits intomainfrom
Draft
feat: add middleware meta support and defineMiddlewareRoute utility#1154productdevbook wants to merge 2 commits intomainfrom
productdevbook wants to merge 2 commits intomainfrom
Conversation
Deploying h3dev with
|
| Latest commit: |
f4963d2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://45712880.h3dev.pages.dev |
| Branch Preview URL: | https://feat-middleware-meta-and-rou.h3dev.pages.dev |
pi0
reviewed
Jul 8, 2025
| return (h3: H3) => { | ||
| const options = { | ||
| ...(def.methods && { | ||
| match: (event: H3Event) => { |
Member
There was a problem hiding this comment.
app.use already adds matching support using normalizeMiddleware internal (see here > here so we don't need to do it again here.
Also #1153 (comment), we could add this functionality to existing defineRoute utility.
pi0
reviewed
Jul 8, 2025
| * | ||
| * @experimental The object structure may change in non-major version. | ||
| */ | ||
| matchedMiddleware?: Array<{ |
Member
There was a problem hiding this comment.
Please remove it from this PR. We need runtime implementation and one PR per feature!
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.
Closes #1153
Description
This PR introduces two new features to improve middleware handling in h3:
defineRouteChanges
1. Middleware Meta Support
meta?: H3RouteMetatoMiddlewareOptionstypenormalizeMiddlewareto handle meta and store it inevent.context.matchedMiddlewarematchedMiddlewarearray toH3EventContexttype to track matched middleware with their metadata2. defineMiddlewareRoute Utility
defineMiddlewarefunction internallydefineRouteUsage Examples
Benefits