@@ -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]
@@ -1096,7 +1099,6 @@ class Server {
1096
1099
? /** @type {ServerConfiguration } */ ( options . server ) . type || "http"
1097
1100
: "http" ,
1098
1101
options : {
1099
- .../** @type {ServerOptions } */ ( options . https ) ,
1100
1102
.../** @type {ServerConfiguration } */ ( options . server || { } ) . options ,
1101
1103
} ,
1102
1104
} ;
@@ -1112,7 +1114,11 @@ class Server {
1112
1114
} ;
1113
1115
}
1114
1116
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
+ ) {
1116
1122
if (
1117
1123
typeof (
1118
1124
/** @type {ServerOptions } */ ( options . server . options ) . requestCert
@@ -2438,16 +2444,17 @@ class Server {
2438
2444
* @returns {void }
2439
2445
*/
2440
2446
createServer ( ) {
2441
- const { type, options } = /** @type { ServerConfiguration } */ (
2442
- this . options . server
2443
- ) ;
2447
+ const { type, options } =
2448
+ /** @type { ServerConfiguration } */
2449
+ ( this . options . server ) ;
2444
2450
2445
- /** @type {import("http").Server | undefined | null } */
2446
2451
// 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 ) ;
2451
2458
2452
2459
/** @type {import("http").Server } */
2453
2460
( this . server ) . on (
0 commit comments