Interface EndpointDefBuilder<Root>

Builder interface to define an endpoint

interface EndpointDefBuilder<Root> {
    root: Root;
    bodyOpt<Body>(body): EndpointDefBuilder<Expand<Root & Record<typeof $bodyOpt, Body>>>;
    bodyOpt<Body, AltResp>(body, altResp): EndpointDefBuilder<Expand<Root & Record<typeof $bodyOpt, Body> & Record<typeof $responseAltBody, AltResp>>>;
    bodyReq<Body>(body): EndpointDefBuilder<Expand<Root & Record<typeof $bodyReq, Body>>>;
    bodyReq<Body, AltResp>(body, altResp): EndpointDefBuilder<Expand<Root & Record<typeof $bodyReq, Body> & Record<typeof $responseAltBody, AltResp>>>;
    error<Error>(error): EndpointDefBuilder<Expand<Root & Record<typeof $error, Error>>>;
    queryOpt<Query>(query): EndpointDefBuilder<Expand<Root & Record<typeof $queryOpt, Query>>>;
    queryOpt<Query, AltResp>(query, altResp): EndpointDefBuilder<Expand<Root & Record<typeof $queryOpt, Query> & Record<typeof $responseAltQuery, AltResp>>>;
    queryReq<Query>(query): EndpointDefBuilder<Expand<Root & Record<typeof $queryReq, Query>>>;
    queryReq<Query, AltResp>(query, altResp): EndpointDefBuilder<Expand<Root & Record<typeof $queryReq, Query> & Record<typeof $responseAltQuery, AltResp>>>;
}

Type Parameters

Properties

root: Root

Definition shape of an endpoint

Methods

  • Provides a shape of the error response an API. This is used to detect API-generated errors that are passed with successful 200 responses

    Type Parameters

    Parameters

    • error: Error

      Shape of the error response

    Returns EndpointDefBuilder<Expand<Root & Record<typeof $error, Error>>>

    Example: Using the error function

    ...get({}, $get =>
    $get.error({ message: '' })
    )...