Proxy API Reference
API Documentation
The full API reference is generated automatically from the source code during the build process.
When you run pnpm docs:build, TypeDoc generates detailed documentation for all exported types, interfaces, classes, and functions.
Main Exports
ProxyServer
The main class for creating a proxy server.
import { ProxyServer } from '@serverless-monolith/proxy';
const proxy = new ProxyServer({
port: 5454,
cors: true,
coreGroups: [...],
});
await proxy.start();
Types
ProxyServerOptions
Main configuration options for the proxy server.
interface ProxyServerOptions {
port?: number;
cors?: boolean;
cores?: CoreConfig[]; // Legacy
coreGroups?: CoreGroup[]; // Recommended
prefix?: string;
defaultTimeout?: number;
logRequests?: boolean;
sqs?: SQSProxyOptions;
}
CoreGroup
Group of routes for a single monolith server.
interface CoreGroup {
coreName: string;
baseUrl: string;
routes: RouteConfigWithoutUrl[];
}
RouteConfigWithoutUrl
Route configuration within a CoreGroup.
interface RouteConfigWithoutUrl {
name: string;
aliases?: string[];
pathPrefix?: string;
timeout?: number;
headers?: Record<string, string>;
routeByPath?: Record<string, RouteTarget>;
}
CoreConfig (Legacy)
Legacy core configuration format.
interface CoreConfig {
name: string;
aliases?: string[];
url?: string;
targets?: CoreTarget[];
loadBalanceStrategy?: LoadBalanceStrategy;
pathPrefix?: string;
timeout?: number;
headers?: Record<string, string>;
routeByPath?: Record<string, CoreTarget>;
}
CoreTarget
Target configuration for routing.
interface CoreTarget {
url: string;
pathPrefix?: string;
timeout?: number;
headers?: Record<string, string>;
weight?: number;
preserveMatchedPath?: boolean;
fallbackUrls?: string[];
transformPath?: (path: string) => string;
}
LoadBalanceStrategy
Load balancing strategy type.
type LoadBalanceStrategy = 'round-robin' | 'failover' | 'random';
SQSProxyOptions
SQS proxy configuration.
interface SQSProxyOptions {
enabled?: boolean;
refreshInterval?: number;
enableManagementRoutes?: boolean;
routePrefix?: string;
discoveryTimeout?: number;
}
Type Exports
import type {
ProxyServerOptions,
CoreGroup,
RouteConfigWithoutUrl,
CoreConfig,
CoreTarget,
LoadBalanceStrategy,
SQSProxyOptions,
} from '@serverless-monolith/proxy';