UNPKG

@stacksjs/rpx

Version:

A modern and smart reverse proxy.

37 lines (36 loc) 1.23 kB
import * as path from 'node:path'; import type { LoadBalancerConfig, PathRewrite, ProxyFrom, StaticRouteConfig } from './types'; /** * Sanitize an arbitrary `to` host into a valid registry id. Drops anything * that isn't `[a-zA-Z0-9._-]`, collapses runs to a single dash, and trims * leading/trailing dashes. Falls back to `'rpx'` if nothing's left. */ export declare function deriveIdFromTarget(to: string, routePath?: string): string; /** * Register every proxy with the daemon and (unless `detached`) block until a * shutdown signal arrives. Throws if any id collides or the daemon fails to * spawn. */ export declare function runViaDaemon(opts: DaemonRunnerOptions): Promise<void>; export declare interface DaemonRunnerProxy { id?: string from?: ProxyFrom to: string path?: string cleanUrls?: boolean changeOrigin?: boolean pathRewrites?: PathRewrite[] static?: string | StaticRouteConfig loadBalancer?: LoadBalancerConfig } export declare interface DaemonRunnerOptions { proxies: DaemonRunnerProxy[] verbose?: boolean registryDir?: string rpxDir?: string detached?: boolean spawnCommand?: string[] startupTimeoutMs?: number spawnEnv?: Record<string, string> persistent?: boolean }