UNPKG

@nestia/fetcher

Version:

Fetcher library of Nestia SDK

48 lines (47 loc) 2.45 kB
import { IConnection } from "./IConnection"; import { IFetchRoute } from "./IFetchRoute"; import { IPropagation } from "./IPropagation"; /** * Utility class for `fetch` functions used in `@nestia/sdk` with encryption. * * `EncryptedFetcher` is a utility class designed for SDK functions generated by * [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote * HTTP API encrypted by AES-PKCS algorithm. In other words, this is a * collection of dedicated `fetch()` functions for `@nestia/sdk` with * encryption. * * For reference, `EncryptedFetcher` class being used only when target * controller method is encrypting body data by `@EncryptedRoute` or * `@EncryptedBody` decorators. If those decorators are not used, * {@link PlainFetcher} class would be used instead. * * @author Jeongho Nam - https://github.com/samchon */ export declare namespace EncryptedFetcher { /** * 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>; }