UNPKG

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