UNPKG

@orpc/standard-server-fetch

Version:

<div align="center"> <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" /> </div>

58 lines (51 loc) 2.68 kB
import { StandardBody, StandardHeaders, StandardLazyRequest, StandardRequest, StandardResponse, StandardLazyResponse } from '@orpc/standard-server'; declare function toEventIterator(stream: ReadableStream<Uint8Array>): AsyncGenerator<unknown | void, unknown | void, void>; interface ToEventStreamOptions { /** * If true, a ping comment is sent periodically to keep the connection alive. * * @default true */ eventIteratorKeepAliveEnabled?: boolean; /** * Interval (in milliseconds) between ping comments sent after the last event. * * @default 5000 */ eventIteratorKeepAliveInterval?: number; /** * The content of the ping comment. Must not include newline characters. * * @default '' */ eventIteratorKeepAliveComment?: string; } declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options?: ToEventStreamOptions): ReadableStream<Uint8Array>; declare function toStandardBody(re: Request | Response): Promise<StandardBody>; interface ToFetchBodyOptions extends ToEventStreamOptions { } /** * @param body * @param headers - The headers can be changed by the function and effects on the original headers. */ declare function toFetchBody(body: StandardBody, headers: Headers, options?: ToFetchBodyOptions): string | Blob | FormData | URLSearchParams | undefined | ReadableStream<Uint8Array>; /** * @param headers * @param standardHeaders - The base headers can be changed by the function and effects on the original headers. */ declare function toStandardHeaders(headers: Headers, standardHeaders?: StandardHeaders): StandardHeaders; /** * @param headers * @param fetchHeaders - The base headers can be changed by the function and effects on the original headers. */ declare function toFetchHeaders(headers: StandardHeaders, fetchHeaders?: Headers): Headers; declare function toStandardLazyRequest(request: Request): StandardLazyRequest; interface ToFetchRequestOptions extends ToFetchBodyOptions { } declare function toFetchRequest(request: StandardRequest, options?: ToFetchRequestOptions): Request; interface ToFetchResponseOptions extends ToFetchBodyOptions { } declare function toFetchResponse(response: StandardResponse, options?: ToFetchResponseOptions): Response; declare function toStandardLazyResponse(response: Response): StandardLazyResponse; export { toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchRequest, toFetchResponse, toStandardBody, toStandardHeaders, toStandardLazyRequest, toStandardLazyResponse }; export type { ToEventStreamOptions, ToFetchBodyOptions, ToFetchRequestOptions, ToFetchResponseOptions };