-
-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathfetchLink.ts
43 lines (38 loc) · 967 Bytes
/
fetchLink.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// TODO: Fetch options
import { LinkFlag, Link, ProceduresDef, JoinLinkFlags } from "..";
/**
* @internal
*/
export type HTTPHeaders = Record<string, string | string[] | undefined>;
export interface FetchLinkOptions {
url: string;
/**
* Add ponyfill for fetch
*/
fetch?: typeof fetch;
// /**
// * Add ponyfill for AbortController
// */
// AbortController?: typeof AbortController | null;
// /**
// * Headers to be set on outgoing requests or a callback that of said headers
// * @link http://trpc.io/docs/v10/header
// */
// headers?: HTTPHeaders | (() => HTTPHeaders | Promise<HTTPHeaders>);
// credentials: "omit" | "same-origin" | "include";
}
export function fetchLink<T extends ProceduresDef>(
opts: FetchLinkOptions
): Link<
T,
T,
{
terminatedLink: true;
subscriptionsUnsupported: true;
}
> {
const fetch = opts.fetch || globalThis.fetch;
return (op) => {
// TODO
};
}