@orpc/client
Version:
<div align="center"> <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" /> </div>
30 lines (26 loc) • 1.01 kB
JavaScript
import { toFetchRequest, toStandardLazyResponse } from '@orpc/standard-server-fetch';
import '@orpc/shared';
import { c as StandardRPCLink } from '../../shared/client.DKmRtVO2.mjs';
import '@orpc/standard-server';
import '../../shared/client.txdq_i5V.mjs';
class LinkFetchClient {
fetch;
toFetchRequestOptions;
constructor(options) {
this.fetch = options?.fetch ?? globalThis.fetch.bind(globalThis);
this.toFetchRequestOptions = options;
}
async call(request, options, path, input) {
const fetchRequest = toFetchRequest(request, this.toFetchRequestOptions);
const fetchResponse = await this.fetch(fetchRequest, { redirect: "manual" }, options, path, input);
const lazyResponse = toStandardLazyResponse(fetchResponse, { signal: fetchRequest.signal });
return lazyResponse;
}
}
class RPCLink extends StandardRPCLink {
constructor(options) {
const linkClient = new LinkFetchClient(options);
super(linkClient, options);
}
}
export { LinkFetchClient, RPCLink };