Conversation
🦋 Changeset detectedLatest commit: 7d47004 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
!preview integration-middleware |
|
|
This can be tried out with: npm install astro@next--integration-middlewareNote that preview releases are temporary and are only intended to test out a feature. |
852ac0f to
b68d770
Compare
| if(typeof updatedSettings.middleware[order] === 'undefined') { | ||
| throw new Error( | ||
| `The "${integration.name}" integration is trying to add middleware but did not specify an order.` | ||
| ); | ||
| } |
There was a problem hiding this comment.
I'm not sure what default makes the most sense, but I wouldn't expect to be required to provide order. For example, a middleware that adds a new route could really go anywhere.
There was a problem hiding this comment.
Hm, I don't like having a default when it's not obvious what the default should be. It really depends on the use-case; if you are doing something that modifies the response you want to be in pre, if you are adding locals then post is fine.
There was a problem hiding this comment.
I agree with Matthew on this one. Since the order is essential and we can't guess what the user intends to do, I think we need to force the user to choose.
| if(typeof updatedSettings.middleware[order] === 'undefined') { | ||
| throw new Error( | ||
| `The "${integration.name}" integration is trying to add middleware but did not specify an order.` | ||
| ); | ||
| } |
There was a problem hiding this comment.
I agree with Matthew on this one. Since the order is essential and we can't guess what the user intends to do, I think we need to force the user to choose.
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
sarah11918
left a comment
There was a problem hiding this comment.
Looks great @matthewp ! Just left some comments on the changeset!
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
ematipico
left a comment
There was a problem hiding this comment.
Looks good. I'm really looking forward to having this feature shipped!
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
* Rebase * Use an empty module if there is no real middleware * Add debug logging * Use normalizePath * Add a better example in the changesetp * Update .changeset/khaki-glasses-raise.md Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> * Update .changeset/khaki-glasses-raise.md Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> * Update .changeset/khaki-glasses-raise.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update .changeset/khaki-glasses-raise.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update .changeset/khaki-glasses-raise.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update .changeset/khaki-glasses-raise.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update packages/astro/src/core/middleware/vite-plugin.ts Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> * Review comments * oops * Update .changeset/khaki-glasses-raise.md Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> --------- Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Changes
Testing
Docs