-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use universal-middleware
#16
Conversation
Hi. I stumbled across this extension while trying to figure out the best way to deploy to Node and it looks awesome. The one issue I have is that I am using Auth.js for authentication and was previously using universal middleware to add the logged in user to the context. When I use the vike-node extension though, my modified context is not being seen by Vike so I assume it's using a different context. I'm assuming these draft changes will mean my context changes will be seen by Vike via the use of universal middleware...is that right? Not sure how far away these changes are, but is there another way that I can add the user to the context using regular middleware so that Vike will see that when I am using vike-node? |
@jasonhilldm I would suggest to wait for this PR to be finished, as it will fix your issue. import { getContext } from "@universal-middleware/hono";
app.use(
vike({
pageContext: (req) => getContext(req)
})
) |
Thank you - that worked perfectly. |
05aa8d6
to
775df55
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started reviewing a bit, I'll resume tomorrow.
Migration
|
How about we push empty commits that include these |
We can force push if you want to edit previous |
90b5029
to
15a298e
Compare
|
Seems like we should be good to merge @brillout |
I think it's even more misleading. Many users will wonder "why should I publish my middleware?". (I guess the docs is automatically copy-pasting real code from examples to the docs. FYI I used to do that as well but I stopped doing it precisely because of things like this.) |
A Also: - BREAKING CHANGE: `getPageContext` has been removed
+ BREAKING CHANGE: the `pageContext` setting has been removed |
LGTM otherwise. I've pushed a couple of commits, let me know if you disagree with any of it. I've mixed feelings about removing the cache. I kinda liked that the compression was being cached, but I ain't sure whether caching should be done inside As for this PR, I'm a bit inclined to remove the compression outside of |
f536a3f
to
2be3c1b
Compare
LGTM
I think that the caching layer do not belong directly in this package. I not even sure that I find the feature useful (have we measured that it really improves perfs?). Regarding the compression, no strong feeling about it. For the sake of merging this PR sooner rather than later, I'd say we keep it as-is for now. |
BREAKING CHANGE: cache related options have been removed ```diff app.use( vike({ compress: false, - static: { - cache: false - } }) ) ``` # Conflicts: # packages/vike-node/src/runtime/vike-handler.ts
This reverts commit 4c31295.
2be3c1b
to
712809f
Compare
This seems to be still missing. |
I see, good point. Indeed computing a cache key isn't gratis either and bloating memory isn't necessarily a good default.
Makes sense 👍
WDYT? |
Hum no, it's there 29128b5 |
I'm currently working on some |
I meant this one:
|
BREAKING CHANGE: `vike-node/connect` replaced by `vike-node/express`
Released as |
I made a couple of improvements to the readme, see the last commits. Let me know if you disagree with anything. |
Thanks! LGTM |
Notable changes
@universal-middleware/compress
for compressiongetPageContext
hook is removed. The wholecontext
from universal middlewares is given as a Context torenderPage
. This means that the same effect can be achieved by any custom universal middleware.Next steps (not in this PR)