( base: string, id: string, instance: string, options: RequestInit, args: any[], )
| 25 | } |
| 26 | |
| 27 | async function initializeResponse( |
| 28 | base: string, |
| 29 | id: string, |
| 30 | instance: string, |
| 31 | options: RequestInit, |
| 32 | args: any[], |
| 33 | ) { |
| 34 | // No args, skip serialization |
| 35 | if (args.length === 0) { |
| 36 | return createRequest(base, id, instance, options); |
| 37 | } |
| 38 | // For single arguments, we can directly encode as body |
| 39 | if (args.length === 1) { |
| 40 | const body = args[0]; |
| 41 | const result = getHeadersAndBody(body); |
| 42 | if (result) { |
| 43 | return createRequest(base, id, instance, { |
| 44 | ...options, |
| 45 | body: result.body, |
| 46 | headers: { |
| 47 | ...options.headers, |
| 48 | ...result.headers, |
| 49 | }, |
| 50 | }); |
| 51 | } |
| 52 | } |
| 53 | // Fallback to seroval |
| 54 | return createRequest(base, id, instance, { |
| 55 | ...options, |
| 56 | // TODO(Alexis): move to serializeToJSONStream |
| 57 | body: await serializeToJSONString(args), |
| 58 | // duplex: 'half', |
| 59 | // body: serializeToJSONStream(args), |
| 60 | headers: { |
| 61 | ...options.headers, |
| 62 | "Content-Type": "text/plain", |
| 63 | [BODY_FORMAT_KEY]: BodyFormat.Seroval, |
| 64 | }, |
| 65 | }); |
| 66 | } |
| 67 | |
| 68 | async function fetchServerFunction( |
| 69 | base: string, |
no test coverage detected
searching dependent graphs…