UNPKG

@podium/proxy

Version:

Transparent http proxy. Dynamically mounts proxy targets on an existing HTTP server instance.

41 lines (40 loc) 1.63 kB
/** * @typedef {object} PodiumProxyOptions * @property {string} [pathname="/"] * @property {string} [prefix="/podium-resource"] * @property {number} [timeout=20000] * @property {number} [maxAge=Infinity] * @property {import('abslog').AbstractLoggerOptions | null} [logger=null] */ export default class PodiumProxy { /** * @constructor * @param {PodiumProxyOptions} options */ constructor({ pathname, prefix, timeout, logger, }?: PodiumProxyOptions); get pathname(): string; get prefix(): string; get metrics(): Metrics; get registry(): Map<any, any>; /** * Register a podlet in the proxy. This will read the proxy configuration from the manifest. * @param {string} name * @param {import('@podium/schemas').PodletManifestSchema} manifest */ register(name: string, manifest: import("@podium/schemas").PodletManifestSchema): void; /** * @param {import('@podium/utils').HttpIncoming} incoming * @returns {Promise<import('@podium/utils').HttpIncoming | undefined>} The incoming request with the `.proxy` property set to true if successfully proxied, or `undefined` if the incoming request didn't match anything registered in the proxy. */ process(incoming: import("@podium/utils").HttpIncoming): Promise<import("@podium/utils").HttpIncoming | undefined>; get [Symbol.toStringTag](): string; #private; } export type PodiumProxyOptions = { pathname?: string; prefix?: string; timeout?: number; maxAge?: number; logger?: import("abslog").AbstractLoggerOptions | null; }; import Metrics from '@metrics/client';