UNPKG

@nestia/fetcher

Version:

Fetcher library of Nestia SDK

44 lines (41 loc) 1.99 kB
import { FetcherBase } from './internal/FetcherBase.mjs'; /** * 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 */ var PlainFetcher; (function (PlainFetcher) { async function fetch(connection, route, input, stringify) { if (route.request?.encrypted === true || route.response?.encrypted === true) throw new Error("Error on PlainFetcher.fetch(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead."); return FetcherBase.request({ className: "PlainFetcher", encode: (input) => input, decode: (input) => input, })(connection, route, input, stringify); } PlainFetcher.fetch = fetch; async function propagate(connection, route, input, stringify) { if (route.request?.encrypted === true || route.response?.encrypted === true) throw new Error("Error on PlainFetcher.propagate(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead."); return FetcherBase.propagate({ className: "PlainFetcher", encode: (input) => input, decode: (input) => input, })(connection, route, input, stringify); } PlainFetcher.propagate = propagate; })(PlainFetcher || (PlainFetcher = {})); export { PlainFetcher }; //# sourceMappingURL=PlainFetcher.mjs.map