UNPKG

958 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}
10/**
11 * An object that requires host and port properties
12 */
13export interface HostPort {
14 host: string;
15 port: number;
16}
17/**
18 * Create an HTTP-server configuration that works well in test environments.
19 * - Ask the operating system to assign a free (ephemeral) port.
20 * - Use IPv4 localhost `127.0.0.1` to avoid known IPv6 issues in Docker-based
21 * environments like Travis-CI.
22 * - Provide default TLS key & cert when `protocol` is set to `https`.
23 *
24 * @param customConfig - Additional configuration options to apply.
25 */
26export declare function givenHttpServerConfig<T extends HttpOptions | HttpsOptions>(customConfig?: T): HostPort & T;