@amadeus-it-group/kassette
Version:
Development server, used mainly for testing, which proxies requests and is able to easily manage local mocks.
48 lines (47 loc) • 1.49 kB
TypeScript
import { IncomingMessage, IncomingHttpHeaders } from 'http';
import { Http2ServerRequest } from 'http2';
import { URL } from 'url';
/**
* A handier wrapper around a request
*
* @public
*/
export interface IFetchedRequest {
/** The original Node.js object representing the request */
readonly original: IncomingMessage | Http2ServerRequest;
/** The connections stack */
readonly connectionsStack: readonly Readonly<Connection>[];
/** The last connection in connectionsStack */
readonly connection: Readonly<Connection>;
/** The URL */
readonly url: URL;
/** The headers */
readonly headers: IncomingHttpHeaders;
/** The query parameters taken from the URL, as a read-only map of strings */
readonly queryParameters: Readonly<Record<string, string>>;
/** The protocol part of the URL, without the trailing `:` */
readonly protocol: string;
/** The hostname part of the URL */
readonly hostname: string;
/** The port part of the URL */
readonly port: string;
/** The HTTP method */
readonly method: string;
/** The path part of the URL */
readonly pathname: string;
/** The body content */
readonly body: Buffer;
}
/**
* A connection intercepted by kassette
*
* @public
*/
export interface Connection {
/** protocol such as `http` or `https`, without the trailing `:` */
protocol: string;
/** target hostname */
hostname: string;
/** target port */
port: number;
}