UNPKG

@sauce-api/core

Version:

Sauce API core functionality

59 lines (58 loc) 2.07 kB
import { RouteParam } from "./RouteParam"; import { HttpMethod } from "../resources/Common"; import { SauceResponseType } from "../resources/IResponses"; /** Configure a route for the application */ export declare class Route { path: string; method: PropertyKey; controller: string; customControllerPath: string; action: PropertyKey; policies: string[]; description: string; tag: string; pathParams: RouteParam[]; queryParams: RouteParam[]; bodySchema: RouteParam[]; private formattedPathParams; private formattedBodySchema; private formattedQueryParams; excludedEnvironments: string[]; hidden: boolean; queryParamKeys: string[]; exampleResponse: SauceResponseType; isDeprecated: boolean; setMethod(method: HttpMethod): Route; setPath(path: string): Route; setCustomControllerPath(customControllerPath: string): Route; setController(controller: string): Route; setAction(action: PropertyKey): Route; setPolicies<T = string[]>(policies: T[] | string[]): Route; setDescription(description: string): Route; setTag<T = string>(tag: T): Route; setPathParams(params: Array<RouteParam>): Route; setQueryParams(queryParams: Array<RouteParam>): Route; setBodySchema(bodySchema: Array<RouteParam>): Route; setExcludedEnvironments(environments: Array<string>): Route; setHidden(hidden: boolean): Route; setExampleResponse(exampleResponse: SauceResponseType): Route; setIsDeprecated(value: boolean): Route; getFormattedPathParams(): any; getFormattedQueryParams(): any; getFormattedBodySchema(): any; /** * A shortcut for determining if a route has * a specific query param configured for it. * * IT WILL NOT DETECT IF THE REQUEST HAS A QUERY * PARAM PRESENT * * @param {sting} key - the query param key to check * @return {boolean} */ hasQueryParam(key: string): boolean; private formatParams; private buildSchema; private buildBodySchemaLevel; private formatParam; }