Interface Route<InputType, OutputType, PathParamsType, QueryParamsType>

Represents a route in an API.

interface Route<InputType, OutputType, PathParamsType, QueryParamsType> {
    handler: TransactionExecution<default<InputType, ResponseErrorType | OutputType, never, PathParamsType, QueryParamsType>, ResponseErrorType | OutputType>;
    inputSchema?: ZodObject<any, UnknownKeysParam, ZodTypeAny, {}, {}> | ZodUnion<any> | ZodIntersection<any, any>;
    method: HttpMethod;
    openApi?: {
        description: string;
        outputSchema?:
            | ZodType<any, ZodTypeDef, any>
            | ZodObject<any, UnknownKeysParam, ZodTypeAny, {}, {}>
            | ZodUnion<any>
            | ZodIntersection<any, any>;
        security?: {
            [key: string]: string[] | never[];
        }[];
        successCode?: number;
        summary: string;
        tags?: string[];
    };
    path: string | string[];
    pathSchema?: ZodObject<any, UnknownKeysParam, ZodTypeAny, {}, {}> | ZodUnion<any> | ZodIntersection<any, any>;
    querySchema?: ZodObject<any, UnknownKeysParam, ZodTypeAny, {}, {}> | ZodUnion<any> | ZodIntersection<any, any>;
}

Type Parameters

  • InputType = never

    The type of the input data for the route.

  • OutputType = never

    The type of the output data for the route.

  • PathParamsType = StringMap
  • QueryParamsType = StringMap

Properties

The handler function for the route.

inputSchema?: ZodObject<any, UnknownKeysParam, ZodTypeAny, {}, {}> | ZodUnion<any> | ZodIntersection<any, any>

The input schema for validating the input data.

method: HttpMethod

The HTTP method of the route.

openApi?: {
    description: string;
    outputSchema?:
        | ZodType<any, ZodTypeDef, any>
        | ZodObject<any, UnknownKeysParam, ZodTypeAny, {}, {}>
        | ZodUnion<any>
        | ZodIntersection<any, any>;
    security?: {
        [key: string]: string[] | never[];
    }[];
    successCode?: number;
    summary: string;
    tags?: string[];
}

An optional openApi object with extra metadata for docs generation.

path: string | string[]

The path of the route.

pathSchema?: ZodObject<any, UnknownKeysParam, ZodTypeAny, {}, {}> | ZodUnion<any> | ZodIntersection<any, any>

The path schema for validating the path data.

querySchema?: ZodObject<any, UnknownKeysParam, ZodTypeAny, {}, {}> | ZodUnion<any> | ZodIntersection<any, any>

The query schema for validating the query data.