@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.
74 lines (73 loc) • 2.64 kB
TypeScript
/**
* Route Validators
*
* This file provides utility functions for validating route configurations.
* These validators help ensure that route configurations are valid and correctly structured.
*/
import type { IRouteConfig, IRouteMatch, IRouteAction } from '../models/route-types.js';
/**
* Validates a port range or port number
* @param port Port number, port range, or port function
* @returns True if valid, false otherwise
*/
export declare function isValidPort(port: any): boolean;
/**
* Validates a domain string
* @param domain Domain string to validate
* @returns True if valid, false otherwise
*/
export declare function isValidDomain(domain: string): boolean;
/**
* Validates a route match configuration
* @param match Route match configuration to validate
* @returns { valid: boolean, errors: string[] } Validation result
*/
export declare function validateRouteMatch(match: IRouteMatch): {
valid: boolean;
errors: string[];
};
/**
* Validates a route action configuration
* @param action Route action configuration to validate
* @returns { valid: boolean, errors: string[] } Validation result
*/
export declare function validateRouteAction(action: IRouteAction): {
valid: boolean;
errors: string[];
};
/**
* Validates a complete route configuration
* @param route Route configuration to validate
* @returns { valid: boolean, errors: string[] } Validation result
*/
export declare function validateRouteConfig(route: IRouteConfig): {
valid: boolean;
errors: string[];
};
/**
* Validate an array of route configurations
* @param routes Array of route configurations to validate
* @returns { valid: boolean, errors: { index: number, errors: string[] }[] } Validation result
*/
export declare function validateRoutes(routes: IRouteConfig[]): {
valid: boolean;
errors: {
index: number;
errors: string[];
}[];
};
/**
* Check if a route configuration has the required properties for a specific action type
* @param route Route configuration to check
* @param actionType Expected action type
* @returns True if the route has the necessary properties, false otherwise
*/
export declare function hasRequiredPropertiesForAction(route: IRouteConfig, actionType: string): boolean;
/**
* Throws an error if the route config is invalid, returns the config if valid
* Useful for immediate validation when creating routes
* @param route Route configuration to validate
* @returns The validated route configuration
* @throws Error if the route configuration is invalid
*/
export declare function assertValidRoute(route: IRouteConfig): IRouteConfig;