UNPKG

@tsed/schema

Version:
46 lines (45 loc) 1.56 kB
import { JsonMethodPath } from "./JsonOperation.js"; /** * Map container for storing HTTP operation paths indexed by method and path. * * JsonOperationPathsMap maintains a collection of operation paths (HTTP method + URL path * combinations) for a controller. It provides efficient lookup and prevents duplicate * operations from being registered. * * ### Key Features * * - **Unique Keys**: Stores operations using `method-path` composite keys * - **Method Safety**: Ensures operations are uniquely identified * - **Efficient Lookup**: Fast retrieval of operations by method and path * - **Type Safety**: Extends Map with JsonMethodPath values * * ### Usage * * ```typescript * const pathsMap = new JsonOperationPathsMap(); * * // Add operation path * const methodPath = { method: "GET", path: "/users" }; * pathsMap.setOperationPath(methodPath); * * // Retrieve by composite key * const operation = pathsMap.get("GET-/users"); * ``` * * ### Key Generation * * The map uses a composite key format: `{method}-{path}` * - Example: `"GET-/users/:id"` for a GET operation on `/users/:id` * - Example: `"POST-/users"` for a POST operation on `/users` * * This ensures that different HTTP methods on the same path are treated as * distinct operations. * * @public */ export declare class JsonOperationPathsMap extends Map<string, JsonMethodPath> { $kind: string; readonly $isJsonDocument = true; setOperationPath(operationPath: JsonMethodPath): void; protected getKey: (method: string, path: any) => string; }