UNPKG

unmock-core

Version:

[![npm](https://img.shields.io/npm/v/unmock-core.svg)][npmjs] [![CircleCI](https://circleci.com/gh/unmock/unmock-js.svg?style=svg)](https://circleci.com/gh/unmock/unmock-js) [![codecov](https://codecov.io/gh/unmock/unmock-js/branch/dev/graph/badge.svg)](h

67 lines 2.12 kB
/// <reference types="node" /> import { ServiceStoreType } from "./service/interfaces"; import { AllowedHosts } from "./settings/allowedHosts"; export { ServiceStoreType }; declare const RESTMethodTypes: readonly ["get", "head", "post", "put", "patch", "delete", "options", "trace"]; export declare type HTTPMethod = typeof RESTMethodTypes[number]; export declare const isRESTMethod: (maybeMethod: string) => maybeMethod is "head" | "get" | "post" | "put" | "patch" | "delete" | "options" | "trace"; export interface ILogger { log(message: string): void; } export interface IListenerInput { req: ISerializedRequest; res?: ISerializedResponse; } export interface IListener { notify(input: IListenerInput): void; } export interface IUnmockOptions extends ILogger { useInProduction(): boolean; isWhitelisted(url: string): boolean; flaky(): boolean; } export interface IUnmockPackage { allowedHosts: AllowedHosts; services: ServiceStoreType; on(): IUnmockPackage; init(): IUnmockPackage; initialize(): IUnmockPackage; off(): void; reloadServices(): void; reset(): void; } export interface IIncomingHeaders { [header: string]: string | string[] | undefined; } export interface IOutgoingHeaders { [header: string]: string | string[] | number | undefined; } export interface IIncomingQuery { [key: string]: string | string[] | undefined; } export interface ISerializedRequest { body?: string | object; headers?: IIncomingHeaders; host: string; method: HTTPMethod; path: string; pathname: string; query: IIncomingQuery; protocol: "http" | "https"; } export interface ISerializedResponse { body?: string; headers?: IOutgoingHeaders; statusCode: number; } export declare type CreateResponse = (request: ISerializedRequest) => ISerializedResponse | undefined; export interface IServiceDefFile { basename: string; contents: string | Buffer; } export interface IServiceDef { absolutePath: string; directoryName: string; serviceFiles: IServiceDefFile[]; } //# sourceMappingURL=interfaces.d.ts.map