koajs / koa

Expressive middleware for node.js using ES2017 async functions

Home Page:https://koajs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

crystalfp opened this issue · comments

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.

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) 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.