Skip to content

Commit ef72b29

Browse files
committed
feat(testlab): add http2 helpers
Signed-off-by: Rifa Achrinza <[email protected]>
1 parent ad85271 commit ef72b29

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/testlab/src/http-server-config.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// License text available at https://opensource.org/licenses/MIT
55

66
import {readFileSync} from 'fs';
7+
import http2 from 'http2';
78
import {ServerOptions as HttpsServerOptions} from 'https';
89
import {ListenOptions} from 'net';
910
import path from 'path';
@@ -22,6 +23,16 @@ export interface HttpsOptions extends ListenOptions, HttpsServerOptions {
2223
protocol: 'https';
2324
}
2425

26+
export interface Http2Options extends ListenOptions, http2.ServerOptions {
27+
protocol: 'http2';
28+
}
29+
30+
export interface Http2sOptions
31+
extends ListenOptions,
32+
http2.SecureServerOptions {
33+
protocol: 'http2s';
34+
}
35+
2536
export type HostPort = {
2637
host: string;
2738
port: number;
@@ -36,9 +47,9 @@ export type HostPort = {
3647
*
3748
* @param customConfig - Additional configuration options to apply.
3849
*/
39-
export function givenHttpServerConfig<T extends HttpOptions | HttpsOptions>(
40-
customConfig?: T,
41-
): HostPort & T {
50+
export function givenHttpServerConfig<
51+
T extends HttpOptions | HttpsOptions | Http2Options | Http2sOptions
52+
>(customConfig?: T): HostPort & T {
4253
const defaults = {
4354
host: '127.0.0.1',
4455
port: 0,

0 commit comments

Comments
 (0)