-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
How to make friends with fastify and express like middleware? #958
Comments
I don't get the idea - the hook in the code manages the |
Thanks to this fake response, I can use any express similar to the middleware and at the same time the following fastify hooks in the chain will work. for example, in onSend I can add a header with a trace. True, there is something wrong with the example, which I discovered later. If the middleware calls res.write and starts writing body, then the headers will be sent to the client and it will no longer be possible to set the headers in the onSend Hook. But it's easy to solve |
I like this solution. it's a kind of express adapter. I can use one middleware, and the code written for fastify will always work. This is better than using a middle plugin, because as soon as you use one middleware, you have to use another, and fastify plugins will not work. and it turns out to be a mess |
Do you have a personal problem? |
Fake response is the Tunnel class, that has Server response methods and It is Duplex Stream at the same time |
Sry for misunderstanding :) |
You have already researched for similar issues?
Yes, I do.
What are you trying to achieve, or the steps to reproduce?
Hi. I really want to make friends with "fastify", "vite dev server" and "svelte/kit".
The problem is that the plugin "svelte/kit" for "vite" is a middleware "express like".
At first I tried using "fastify/middie". It worked. But since the "svelte/kit middleware" directly interacts with the response, the fastifay hooks stop working. This is expected, as it is written in the documentation.
But I am not satisfied with this behavior.
For this reason, I had the idea to do this:
Do you think this is an acceptable solution?
The text was updated successfully, but these errors were encountered: