UNPKG

@zimic/interceptor

Version:

Next-gen TypeScript-first HTTP intercepting and mocking

63 lines (56 loc) 3.37 kB
/** * An error thrown when the interceptor server is running and some operation requires it to be stopped first. * * @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `@zimic/interceptor/server` API reference} */ declare class RunningInterceptorServerError extends Error { constructor(additionalMessage: string); } /** An error thrown when the interceptor server is not running. */ declare class NotRunningInterceptorServerError extends Error { constructor(); } /** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */ interface InterceptorServerOptions { /** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */ hostname?: string; /** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */ port?: number; /** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */ logUnhandledRequests?: boolean; /** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */ tokensDirectory?: string; } /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */ interface InterceptorServer { /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */ hostname: string; /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */ port: number | undefined; /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */ logUnhandledRequests: boolean; /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */ tokensDirectory?: string; /** * @readonly * @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */ get isRunning(): boolean; /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */ start: () => Promise<void>; /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */ stop: () => Promise<void>; } /** The default access control headers for the server. */ declare const DEFAULT_ACCESS_CONTROL_HEADERS: Readonly<{ 'access-control-allow-origin': "*"; 'access-control-allow-methods': string; 'access-control-allow-headers': "*"; 'access-control-expose-headers': "*"; 'access-control-max-age': string | undefined; }>; /** The default status code for the preflight request. */ declare const DEFAULT_PREFLIGHT_STATUS_CODE = 204; /** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */ declare function createInterceptorServer(options?: InterceptorServerOptions): InterceptorServer; export { DEFAULT_ACCESS_CONTROL_HEADERS, DEFAULT_PREFLIGHT_STATUS_CODE, type InterceptorServer, type InterceptorServerOptions, NotRunningInterceptorServerError, RunningInterceptorServerError, createInterceptorServer };