UNPKG

cumulocity-cypress

Version:
116 lines (115 loc) 4.65 kB
import express, { Express, RequestHandler } from "express"; import winston from "winston"; import morgan from "morgan"; import { Server } from "http"; import { C8yDefaultPact, C8yPact, C8yPactRecordingMode, C8yPactMode } from "../c8ypact"; import { C8yPactHttpControllerOptions } from "./httpcontroller-options"; import { C8yPactFileAdapter } from "../c8ypact/adapter/fileadapter"; import { C8yAuthOptions } from "../auth"; import { C8yBaseUrl, C8yTenant } from "../types"; export declare class C8yPactHttpController { currentPact?: C8yDefaultPact; readonly port: number; readonly hostname?: string; protected _baseUrl?: C8yBaseUrl; protected _staticRoot?: string; readonly tenant?: C8yTenant; adapter?: C8yPactFileAdapter; protected _recordingMode: C8yPactRecordingMode; protected _mode: C8yPactMode; protected _isStrictMocking: boolean; protected staticApps: { [key: string]: string; }; protected authOptions?: C8yAuthOptions; protected server?: Server; readonly app: Express; readonly options: C8yPactHttpControllerOptions; readonly resourcePath: string; readonly logger: winston.Logger; protected mockHandler?: RequestHandler; protected proxyHandler?: RequestHandler; constructor(options: C8yPactHttpControllerOptions); /** * Base URL of the target server to proxy requests to. * @example "https://mytenant.eu-latest.cumulocity.com" */ get baseUrl(): string | undefined; /** * Root folder for static files to serve. The controller will serve static files from this folder. * @example "/path/to/static/root" */ get staticRoot(): string | undefined; get recordingMode(): C8yPactRecordingMode; set recordingMode(mode: C8yPactRecordingMode); get mode(): C8yPactMode; set mode(mode: C8yPactMode); isRecordingEnabled(): boolean; isMockingEnabled(): boolean; /** * Starts the server. When started, the server listens on the configured port and hostname. If required, * the server will try to login to the target server using the provided credentials. If authOptions have * a token, the server will use this token for authentication. To enforce BasicAuth, set the type * property of the authOptions to "BasicAuth". */ start(): Promise<void>; /** * Stops the server. */ stop(): Promise<void>; protected registerOpenAPIRequestHandler(): void; protected registerStaticRootRequestHandler(): Promise<void>; protected registerC8yctrlInterface(): void; protected getStatus(): { status: string; uptime: number; version: any; adapter: string | null; baseUrl: string | null; tenant: string | null; current: { id: string | null; }; static: { root: string | null; required: { [key: string]: string; } | null; apps: { [key: string]: string; }; }; mode: "record" | "recording" | "apply" | "forward" | "disabled" | "mock"; supportedModes: readonly ["record", "recording", "apply", "forward", "disabled", "mock"]; recording: { recordingMode: "append" | "refresh" | "new" | "replace"; supportedRecordingModes: readonly ["refresh", "append", "new", "replace"]; isRecordingEnabled: boolean; }; mocking: { isMockingEnabled: boolean; strictMocking: boolean; }; logger: { level: string; }; }; protected mockRequestHandler: RequestHandler; protected stringifyReplacer: (key: string, value: any) => any; getStringifyReplacer(): (key: string, value: any) => any; stringify(obj?: any): string; protected stringifyPact(pact: C8yDefaultPact | C8yPact | any): string; protected producerForPact(pact: C8yPact): { name: string; version?: string; } | undefined; protected pactsForProducer(pacts: { [key: string]: C8yDefaultPact; }, producer: string | { name: string; version: string; }, version?: string): C8yPact[]; savePact(response: Cypress.Response<any> | C8yPact, pactForId?: C8yPact): Promise<boolean>; protected getObjectWithKeys(objs: any[], keys: string[]): any[]; } export declare function morganErrorOptions(logger?: winston.Logger | undefined): morgan.Options<express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, express.Response<any, Record<string, any>>>;