UNPKG

904 BTypeScriptView Raw
1/// <reference types="node" />
2import { ServerOptions as HttpsServerOptions } from 'https';
3import { ListenOptions } from 'net';
4export interface HttpOptions extends ListenOptions {
5 protocol?: 'http';
6}
7export interface HttpsOptions extends ListenOptions, HttpsServerOptions {
8 protocol: 'https';
9}
10export declare type HostPort = {
11 host: string;
12 port: number;
13};
14/**
15 * Create an HTTP-server configuration that works well in test environments.
16 * - Ask the operating system to assign a free (ephemeral) port.
17 * - Use IPv4 localhost `127.0.0.1` to avoid known IPv6 issues in Docker-based
18 * environments like Travis-CI.
19 * - Provide default TLS key & cert when `protocol` is set to `https`.
20 *
21 * @param customConfig - Additional configuration options to apply.
22 */
23export declare function givenHttpServerConfig<T extends HttpOptions | HttpsOptions>(customConfig?: T): HostPort & T;