UNPKG

@nestia/fetcher

Version:

Fetcher library of Nestia SDK

47 lines (46 loc) 2.44 kB
import { IConnection } from "./IConnection"; import { IFetchRoute } from "./IFetchRoute"; import { IPropagation } from "./IPropagation"; /** * Utility class for `fetch` functions used in `@nestia/sdk`. * * `PlainFetcher` is a utility class designed for SDK functions generated by * [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote * HTTP sever API. In other words, this is a collection of dedicated `fetch()` * functions for `@nestia/sdk`. * * For reference, `PlainFetcher` class does not encrypt or decrypt the body data * at all. It just delivers plain data without any post processing. If you've * defined a controller method through `@EncryptedRoute` or `@EncryptedBody` * decorator, then {@liink EncryptedFetcher} class would be used instead. * * @author Jeongho Nam - https://github.com/samchon */ export declare namespace PlainFetcher { /** * Fetch function only for `HEAD` method. * * @param connection Connection information for the remote HTTP server * @param route Route information about the target API * @returns Nothing because of `HEAD` method */ function fetch(connection: IConnection, route: IFetchRoute<"HEAD">): Promise<void>; /** * Fetch function only for `GET` method. * * @param connection Connection information for the remote HTTP server * @param route Route information about the target API * @returns Response body data from the remote API */ function fetch<Output>(connection: IConnection, route: IFetchRoute<"GET">): Promise<Output>; /** * Fetch function for the `POST`, `PUT`, `PATCH` and `DELETE` methods. * * @param connection Connection information for the remote HTTP server * @param route Route information about the target API * @returns Response body data from the remote API */ function fetch<Input, Output>(connection: IConnection, route: IFetchRoute<"POST" | "PUT" | "PATCH" | "DELETE">, input?: Input, stringify?: (input: Input) => string): Promise<Output>; function propagate<Output extends IPropagation<any, any>>(connection: IConnection, route: IFetchRoute<"GET" | "HEAD">): Promise<Output>; function propagate<Input, Output extends IPropagation<any, any>>(connection: IConnection, route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">, input?: Input, stringify?: (input: Input) => string): Promise<Output>; }