-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Make SvelteKit compatible with server middlewares #1610
Comments
The idea that Rich had suggested was to build a converter between the SvelteKit and Express request and response objects |
That works, but if they're convertible, I wonder what's the appeal of exposing the custom types in the first place, and for adapter-node, that seems to mean converting back and forth? |
@benmccann Is that suggestion tracked in this repo somewhere? It would make the Firebase adapter (which uses Express APIs) much easier to integrate. |
We didn't want to use Express types because not all adapters provide an Express request / response the way adapter-node does.
I think this is the best issue tracking it |
This is a retread of #334. When this was being discussed internally in March (rather heatedly!), where I believe we landed was that, if someone cared enough about supporting the Express middleware API, there could be a community-maintained interop library between that API and what the The outcome of the conversation at the time was summarized in #334 (comment) and I don't know how much of the thinking has changed since then. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
this is done now. please see the faq and |
Is your feature request related to a problem? Please describe.
There are a lot of issues that either ask for server side features like SSE, websocket, etc or directly for server side middlewares.
I think the root issue is that the
handle
hook exposes its own types for request and response, which are not compatible with express middlewares that is the de facto standard in Node.I get the rationale behind this design, as @Rich-Harris said in #334
However, the current design feels more like making adapter-node a second-class citizen in order to treat every adapter the same.
I recently came across https://github.com/vendia/serverless-express, which seems to contain a solution to this problem.
Describe the solution you'd like
This code converts a request-like object into
http.IncomingMessage
(there is similar code forhttp.ServerResponse
)https://github.com/vendia/serverless-express/blob/5cd87c8e7ca3a5e971d26d471cb70a6ac15cc61f/src/request.js#L7-L16
And it's the cornerstone for using middlewares in a serverless environment.
I wonder if it's a good idea to make the
handle
hook (maybe also endpoints) exposehttp.IncomingMessage
andhttp.ServerResponse
instead? Foradaptor-node
, the corresponding objects from polka are directly returned, for other adaptors, the aforementioned polyfill is applied.This should open Svelte Kit to the vast amount of server middlewares that are available.
Describe alternatives you've considered
How important is this feature to you?
Very, not being able use existing middlewares is a deal breaker for many people from the referenced issues.
But it's actually possible to polyfill in userland to use the middlewares.
Additional context
The text was updated successfully, but these errors were encountered: