[feat] allow node adapter to configure listen path#2048
Conversation
🦋 Changeset detectedLatest commit: a1cbc29 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
80c162c to
08bcf29
Compare
|
@matths can you update the PR so that the Lint job passes? |
If you got #2051 merged would you no longer need this PR then? Because I think the more we can expose the underlying to allow users to configure it directly that's better vs trying to add all the options here individually |
|
yes, I agree, we can skip and close this PR as I'll focus on #2051. |
c4bd0aa to
028b7a1
Compare
The build and run process using the current @sveltejs/adapter-node only allows to run the final node project listening to either host/port or 0.0.0.0/port specified by an environment variable.
I would expect it to allow listening to a path instead as specified by node, check documentation https://nodejs.org/api/net.html#net_server_listen_path_backlog_callback
Use case:
When using a reverse proxy that expects the node application to listen for a path (domain socket file) instead of a host and port, this was currently not available in the node-adapter.
With this pull request I want to make an offer for this missing feature.
With this feature branch applied yo can now do
SERVER_PATH=/tmp/socket node buildto have your server listen to a domain socket file instead of a port.I think this is somewhat related to the #1610 as this would be the other attempt to solve this problem. If the node-apapter would lead to a middleware instead of a whole node server, the developer would be free to have his own node server and have it listen to a domain socket file instead of host/port.
Tests
I did clone the existing smoke test for this use case.
And I used the changed adapter-node within my project:
packages/adapter-noderunpnpn buildcp packages/adapter-node/index.js packages/adapter-node/index.d.ts packages/adapter-node/files/* ~/myproject/src/lib/import adapter from './src/lib/adapter-node/index.js';instead ofimport adapter from '@sveltejs/adapter-node';in your projects svelte.config.jsSERVER_PATH=/tmp/socket node buildChangeset
I tried to include a changeset, but I am not sure which files to add.