UNPKG

@specprotected/spec-proxy-service-worker

Version:

Server Worker API implementation for integrating with Spec Proxy from an Edge Worker

32 lines (31 loc) 1.47 kB
export declare enum RequestType { Inline = 0, Origin = 1, Mirrored = 2 } export type PlatformRequest = new (url: RequestInfo, info?: RequestInit, original?: Request, config?: SpecConfiguration, requestType?: RequestType) => Request; export interface SpecConfiguration { disableSpecProxy?: boolean; inlineMode?: boolean; percentageOfIPs?: number; customerKey?: string; disableSpecTraffic?: boolean; domainOverride?: string; splitExchangeMirroring?: boolean; debug?: boolean; localDev?: boolean; } export interface ExecutionContext { request: Request; waitUntil(f: Promise<any>): void; } export declare function specProxyProcessRequest(event: ExecutionContext, config?: SpecConfiguration, requestConstructor?: PlatformRequest): RequestData; export declare function specProxyProcessResponse(event: ExecutionContext, req: RequestData, response: Response, config?: SpecConfiguration, requestConstructor?: PlatformRequest): Response; export declare function specProxyProcess(event: ExecutionContext, config: SpecConfiguration, requestConstructor: PlatformRequest): Promise<Response>; export declare function specMakeRequestWithFallback(event: ExecutionContext, request: Request, config: SpecConfiguration, requestConstructor: PlatformRequest): Promise<Response>; export type RequestData = { specUrl: URL; originalUrl: URL; request: Request; requestBodyForResponseProcessing: ReadableStream | null; };