koa
koa copied to clipboard
[feat] Could a listen() shortcut function be added also for http2?
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
- [x] I have searched through GitHub issues for similar issues.
- [x] I have completely read through the README and documentation.
FYI You could quite easily add this yourself as well by extending Koa.
class MyKoa extends Koa {
listenSecure(...args) {
return http2.createSecureServer(...)
}
}
Nice! But adding this myself does not decreases the code lines in my code. For this I proposed it as a new feature.
Describe the feature
There is a shorthand
listen(...args)
(line 86 in application.js) forhttp.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.
Submitted a PR for this here https://github.com/koajs/koa/pull/1833