@@ -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]
@@ -1071,7 +1074,6 @@ class Server {
10711074 ? /** @type {ServerConfiguration } */ ( options . server ) . type || "http"
10721075 : "http" ,
10731076 options : {
1074- .../** @type {ServerOptions } */ ( options . https ) ,
10751077 .../** @type {ServerConfiguration } */ ( options . server || { } ) . options ,
10761078 } ,
10771079 } ;
@@ -1087,7 +1089,11 @@ class Server {
10871089 } ;
10881090 }
10891091
1090- if ( options . server . type === "https" || options . server . type === "spdy" ) {
1092+ if (
1093+ options . server . type === "https" ||
1094+ options . server . type === "http2" ||
1095+ options . server . type === "spdy"
1096+ ) {
10911097 if (
10921098 typeof (
10931099 /** @type {ServerOptions } */ ( options . server . options ) . requestCert
@@ -2413,16 +2419,17 @@ class Server {
24132419 * @returns {void }
24142420 */
24152421 createServer ( ) {
2416- const { type, options } = /** @type { ServerConfiguration } */ (
2417- this . options . server
2418- ) ;
2422+ const { type, options } =
2423+ /** @type { ServerConfiguration } */
2424+ ( this . options . server ) ;
24192425
2420- /** @type {import("http").Server | undefined | null } */
24212426 // eslint-disable-next-line import/no-dynamic-require
2422- this . server = require ( /** @type {string } */ ( type ) ) . createServer (
2423- options ,
2424- this . app ,
2425- ) ;
2427+ const serverType = require ( /** @type {string } */ ( type ) ) ;
2428+ /** @type {import("http").Server | import("http2").Http2SecureServer | undefined | null } */
2429+ this . server =
2430+ type === "http2"
2431+ ? serverType . createSecureServer ( options , this . app )
2432+ : serverType . createServer ( options , this . app ) ;
24262433
24272434 /** @type {import("http").Server } */
24282435 ( this . server ) . on (
0 commit comments