@paultaku/node-mock-server
Version:
A TypeScript-based mock server with automatic Swagger-based mock file generation
36 lines • 1.4 kB
TypeScript
/**
* Route Matcher
*
* Matches incoming HTTP requests to mock file directories.
* Handles path parameter templates (e.g., /user/{userId}).
*/
/**
* Get all mock endpoint templates
* Recursively walks the mock directory to find all endpoints
* @param mockRoot - Mock root directory
* @returns Array of template arrays (e.g., [['user', '{userId}', 'GET']])
*/
export declare function getAllMockTemplates(mockRoot: string): Promise<string[][]>;
/**
* Match result containing the matched template and extracted path parameters
*/
export interface MatchResult {
template: string[];
params: Record<string, string>;
}
/**
* Match a request path to an endpoint template
* Handles path parameters like /user/{userId} matching /user/123
* @param requestParts - Request path parts (e.g., ['user', '123'])
* @param templates - All available endpoint templates
* @param method - HTTP method
* @returns Match result with template and params, or null if no match
*/
export declare function matchTemplate(requestParts: string[], templates: string[][], method: string): MatchResult | null;
/**
* Get all available mock files for an endpoint directory
* @param endpointDir - Directory containing mock response files
* @returns Array of mock filenames
*/
export declare function getAvailableMockFiles(endpointDir: string): Promise<string[]>;
//# sourceMappingURL=route-matcher.d.ts.map