@@ -101,9 +101,13 @@ const schema = require("./options.json");
101
101
* @property {false | WatchOptions } watch
102
102
*/
103
103
104
+ /**
105
+ * @typedef {"http" | "https" | "spdy" | "http2" | string } ServerType
106
+ */
107
+
104
108
/**
105
109
* @typedef {Object } ServerConfiguration
106
- * @property {"http" | "https" | "spdy" | string } [type]
110
+ * @property {ServerType } [type]
107
111
* @property {ServerOptions } [options]
108
112
*/
109
113
@@ -210,8 +214,7 @@ const schema = require("./options.json");
210
214
* @property {boolean | Record<string, never> | BonjourOptions } [bonjour]
211
215
* @property {string | string[] | WatchFiles | Array<string | WatchFiles> } [watchFiles]
212
216
* @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]
215
218
* @property {() => Promise<T> } [app]
216
219
* @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration } [webSocketServer]
217
220
* @property {ProxyConfigArray } [proxy]
@@ -1071,7 +1074,6 @@ class Server {
1071
1074
? /** @type {ServerConfiguration } */ ( options . server ) . type || "http"
1072
1075
: "http" ,
1073
1076
options : {
1074
- .../** @type {ServerOptions } */ ( options . https ) ,
1075
1077
.../** @type {ServerConfiguration } */ ( options . server || { } ) . options ,
1076
1078
} ,
1077
1079
} ;
@@ -1087,7 +1089,11 @@ class Server {
1087
1089
} ;
1088
1090
}
1089
1091
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
+ ) {
1091
1097
if (
1092
1098
typeof (
1093
1099
/** @type {ServerOptions } */ ( options . server . options ) . requestCert
@@ -2413,16 +2419,17 @@ class Server {
2413
2419
* @returns {void }
2414
2420
*/
2415
2421
createServer ( ) {
2416
- const { type, options } = /** @type { ServerConfiguration } */ (
2417
- this . options . server
2418
- ) ;
2422
+ const { type, options } =
2423
+ /** @type { ServerConfiguration } */
2424
+ ( this . options . server ) ;
2419
2425
2420
- /** @type {import("http").Server | undefined | null } */
2421
2426
// 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 ) ;
2426
2433
2427
2434
/** @type {import("http").Server } */
2428
2435
( this . server ) . on (
0 commit comments