UNPKG

@push.rocks/smartproxy

Version:

A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.

80 lines (79 loc) 2.95 kB
/** * Route Utilities * * This file provides utility functions for working with route configurations, * including merging, finding, and managing route collections. */ import type { IRouteConfig } from '../models/route-types.js'; /** * Merge two route configurations * The second route's properties will override the first route's properties where they exist * @param baseRoute The base route configuration * @param overrideRoute The route configuration with overriding properties * @returns A new merged route configuration */ export declare function mergeRouteConfigs(baseRoute: IRouteConfig, overrideRoute: Partial<IRouteConfig>): IRouteConfig; /** * Check if a route matches a domain * @param route The route to check * @param domain The domain to match against * @returns True if the route matches the domain, false otherwise */ export declare function routeMatchesDomain(route: IRouteConfig, domain: string): boolean; /** * Check if a route matches a port * @param route The route to check * @param port The port to match against * @returns True if the route matches the port, false otherwise */ export declare function routeMatchesPort(route: IRouteConfig, port: number): boolean; /** * Check if a route matches a path * @param route The route to check * @param path The path to match against * @returns True if the route matches the path, false otherwise */ export declare function routeMatchesPath(route: IRouteConfig, path: string): boolean; /** * Check if a route matches headers * @param route The route to check * @param headers The headers to match against * @returns True if the route matches the headers, false otherwise */ export declare function routeMatchesHeaders(route: IRouteConfig, headers: Record<string, string>): boolean; /** * Find all routes that match the given criteria * @param routes Array of routes to search * @param criteria Matching criteria * @returns Array of matching routes sorted by priority */ export declare function findMatchingRoutes(routes: IRouteConfig[], criteria: { domain?: string; port?: number; path?: string; headers?: Record<string, string>; }): IRouteConfig[]; /** * Find the best matching route for the given criteria * @param routes Array of routes to search * @param criteria Matching criteria * @returns The best matching route or undefined if no match */ export declare function findBestMatchingRoute(routes: IRouteConfig[], criteria: { domain?: string; port?: number; path?: string; headers?: Record<string, string>; }): IRouteConfig | undefined; /** * Create a route ID based on route properties * @param route Route configuration * @returns Generated route ID */ export declare function generateRouteId(route: IRouteConfig): string; /** * Clone a route configuration * @param route Route to clone * @returns Deep copy of the route */ export declare function cloneRoute(route: IRouteConfig): IRouteConfig;