-
Notifications
You must be signed in to change notification settings - Fork 44
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
feat: add createServer
option
#38
Conversation
Hi @tangye1234 @schonert ! I believe this is a good feature. You don't need to go into detail, but could you please review it? |
serve({ | ||
fetch: app.fetch, | ||
createServer: createServer, | ||
serverOptions: { |
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'd suggest leaving the serverOptions
out by simply using the createServer as a function. Not seen the serverOption
documented or a similar pattern used by other adaptors. Could potentially be a breaking change tho.
serve({
fetch: app.fetch,
createServer: (options = {}) => {
return createServer({
...options,
key: fs.readFileSync('test/fixtures/keys/agent1-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent1-cert.pem'),
})
},
})
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.
Okay! I think you are right.
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.
Ah, if we don't use serverOptions
, we have to pass requestListener
to createServer as an argument:
const server = createAdaptorServer({
fetch: app.fetch,
createServer: (options = {}, requestListener: RequestListener) => {
return createServerHTTPS(
{
...options,
key: fs.readFileSync('test/fixtures/keys/agent1-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent1-cert.pem'),
},
requestListener // <---
)
},
})
It's a little bit annoying, so, keep using serverOptions
.
Brilliant! I only had one comment :) |
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.
This functionality can indeed resolve the HTTPS server problem, and the API suits me well. Looking ahead, it may require additional instrumentation like OpenTelemetry, so exposing the server creation option is an effective means of facilitating integration.
Thanks for reviewing. Let's go with it! |
This PR introduces the
createServer
option for bothserve
andcreateAdaptorServer
. With this option, you can use thecreateServer
function imported fromnode:https
. This feature enables SSL support.Resolve #37