@@ -101,9 +101,13 @@ const schema = require("./options.json");
101101 * @property {false | WatchOptions } watch
102102 */
103103
104+ /**
105+ * @typedef {"http" | "https" | "spdy" | "http2" | string } ServerType
106+ */
107+
104108/**
105109 * @typedef {Object } ServerConfiguration
106- * @property {"http" | "https" | "spdy" | string } [type]
110+ * @property {ServerType } [type]
107111 * @property {ServerOptions } [options]
108112 */
109113
@@ -210,8 +214,7 @@ const schema = require("./options.json");
210214 * @property {boolean | Record<string, never> | BonjourOptions } [bonjour]
211215 * @property {string | string[] | WatchFiles | Array<string | WatchFiles> } [watchFiles]
212216 * @property {boolean | string | Static | Array<string | Static> } [static]
213- * @property {boolean | ServerOptions } [https]
214- * @property {"http" | "https" | "spdy" | string | ServerConfiguration } [server]
217+ * @property {ServerType | ServerConfiguration } [server]
215218 * @property {() => Promise<T> } [app]
216219 * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration } [webSocketServer]
217220 * @property {ProxyConfigArray } [proxy]
@@ -1096,7 +1099,6 @@ class Server {
10961099 ? /** @type {ServerConfiguration } */ ( options . server ) . type || "http"
10971100 : "http" ,
10981101 options : {
1099- .../** @type {ServerOptions } */ ( options . https ) ,
11001102 .../** @type {ServerConfiguration } */ ( options . server || { } ) . options ,
11011103 } ,
11021104 } ;
@@ -1112,7 +1114,11 @@ class Server {
11121114 } ;
11131115 }
11141116
1115- if ( options . server . type === "https" || options . server . type === "spdy" ) {
1117+ if (
1118+ options . server . type === "https" ||
1119+ options . server . type === "http2" ||
1120+ options . server . type === "spdy"
1121+ ) {
11161122 if (
11171123 typeof (
11181124 /** @type {ServerOptions } */ ( options . server . options ) . requestCert
@@ -2438,16 +2444,17 @@ class Server {
24382444 * @returns {void }
24392445 */
24402446 createServer ( ) {
2441- const { type, options } = /** @type { ServerConfiguration } */ (
2442- this . options . server
2443- ) ;
2447+ const { type, options } =
2448+ /** @type { ServerConfiguration } */
2449+ ( this . options . server ) ;
24442450
2445- /** @type {import("http").Server | undefined | null } */
24462451 // eslint-disable-next-line import/no-dynamic-require
2447- this . server = require ( /** @type {string } */ ( type ) ) . createServer (
2448- options ,
2449- this . app ,
2450- ) ;
2452+ const serverType = require ( /** @type {string } */ ( type ) ) ;
2453+ /** @type {import("http").Server | import("http2").Http2SecureServer | undefined | null } */
2454+ this . server =
2455+ type === "http2"
2456+ ? serverType . createSecureServer ( options , this . app )
2457+ : serverType . createServer ( options , this . app ) ;
24512458
24522459 /** @type {import("http").Server } */
24532460 ( this . server ) . on (
0 commit comments