Skip to content
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] Could a listen() shortcut function be added also for http2? #1756

Open
2 tasks done
crystalfp opened this issue Mar 29, 2023 · 3 comments
Open
2 tasks done

[feat] Could a listen() shortcut function be added also for http2? #1756

crystalfp opened this issue Mar 29, 2023 · 3 comments

Comments

@crystalfp
Copy link

Describe the feature

There is a shorthand listen(...args) (line 86 in application.js) for http.createServer(app.callback()).listen(...) but no shorthand for:

http2.createSecureServer(options, app.callback()).listen(...)

Could it be added? This way will be solved also a recent typing problem created by callback() return type.
Thanks!

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
@iwanofski
Copy link

FYI You could quite easily add this yourself as well by extending Koa.

class MyKoa extends Koa {
  listenSecure(...args) {
    return http2.createSecureServer(...)
  }
}

@crystalfp
Copy link
Author

Nice! But adding this myself does not decreases the code lines in my code.
For this I proposed it as a new feature.

@siakc
Copy link

siakc commented Dec 22, 2023

Describe the feature

There is a shorthand listen(...args) (line 86 in application.js) for http.createServer(app.callback()).listen(...) but no shorthand for:

http2.createSecureServer(options, app.callback()).listen(...)

Could it be added? This way will be solved also a recent typing problem created by callback() return type. Thanks!

It is not possible as the http2 is not imported into Koa and I guess http2 is not officially supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants