(input: { url: string; method: string; headers: Record<string, string>; body?: string })
| 29 | |
| 30 | export const rpc = { |
| 31 | async fetch(input: { url: string; method: string; headers: Record<string, string>; body?: string }) { |
| 32 | const headers = { ...input.headers } |
| 33 | const auth = ServerAuth.header() |
| 34 | if (auth && !headers["authorization"] && !headers["Authorization"]) { |
| 35 | headers["Authorization"] = auth |
| 36 | } |
| 37 | const request = new Request(input.url, { |
| 38 | method: input.method, |
| 39 | headers, |
| 40 | body: input.body, |
| 41 | }) |
| 42 | const response = await Server.Default().app.fetch(request) |
| 43 | const body = await response.text() |
| 44 | return { |
| 45 | status: response.status, |
| 46 | headers: Object.fromEntries(response.headers.entries()), |
| 47 | body, |
| 48 | } |
| 49 | }, |
| 50 | snapshot() { |
| 51 | const result = writeHeapSnapshot("server.heapsnapshot") |
| 52 | return result |
no test coverage detected